主题:  ColdFusion vs. ASP.NET

woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#12005/10/25 22:48:14
ASP.NET
Dim sales_cutoff As Integer = 1000
Dim myConnection As SqlConnection = New SqlConnection("connection_string"
Dim myCommand As SqlCommand = myConnection.CreateCommand()
myCommand.CommandText = "SELECT title_id, title, ytd_sales FROM
titles WHERE ytd_sales >= @sales ORDER BY ytd_sales DESC"
myCommand.Parameters.Add("@sales", SqlDbType.Int).value
= sales_cutoff
Dim SqlDataAdapter myAdapter = New SqlDataAdapter(myCommand)
Dim topSellers As DataSet = New DataSet()
myAdapter.Fill(topSellers, "titles"

CFML
<CFSET sales_cutoff = 1000>
<CFQUERY NAME="topSellers"
DATASOURCE="dsn">
SELECT title_id, title, ytd_sales
FROM titles
WHERE ytd_sales >=
<CFQUERYPARAM value="#sales_cutoff#" CFSQLType="CF_SQL_INTEGER">
ORDER BY ytd_sales DESC
</CFQUERY>



woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#22005/10/25 22:48:36
ASP.NET
Dim myMail As MailMessage = New MailMessage()
myMail.From = "foo@bar.com"
myMail.To = "bar@foo.com"
myMail.Subect = "Test Message"
myMail.Body = "This is a test message."
SmtpMail.Send(myMail)

CFML
<CFMAIL TO="foo@bar.com"
FROM="bar@foo.com"
SUBJECT="Test Message">
This is a test message
</CFMAIL>



woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#32005/10/25 22:48:58
ASP.NET
Dim connString as String
connString = "..."
Dim objConnection as OleDbConnection
objConnection = New OleDbConnection(connString)
objConnection.Open()
Dim strSQL as String = "SELECT firstName, email FROM users"
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)
Dim objDataReader as OleDbDataReader
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim myMail As MailMessage = New MailMessage()
myMail.From = "foo@bar.com"
myMail.To = objDataReader("eMail"
myMail.Subect = "Test Message"
myMail.Body = "Dear" & objDataReader("firstName" & " ..."
SmtpMail.Send(myMail)
objDataReader.Close()

CFML
<CFQUERY DATASOURCE="dsn"
NAME="users">
SELECT firstName, email FROM users
</CFQUERY>
<CFMAIL QUEREY="users"
TO="#email#"
FROM="bar@foo.com"
SUBJECT="Test Message">
Dear #firstname#, ...
</CFMAIL>



woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#42005/10/25 22:49:23
ASP.NET
Dim myWebClient As System.Net.WebClient
myWebClient = New System.Net.WebClient()
Dim buffer As Byte()
buffer = myWebClient.DownloadData("http://www.macromedia.com/"
Dim content As String
content = System.Text.Encoding.UTF8.GetString(buffer)
Response.Write(Server.HtmlEncode(content))

CFML
<CFHTTP URL="http://www.macromedia.com/" METHOD="GET">
<CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT>



woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#52005/10/25 22:50:25
ASP.NET
Dim myWebClient As System.Net.WebClient
myWebClient = New System.Net.WebClient()
Dim buffer As Byte()
buffer = myWebClient.DownloadData("http://www.macromedia.com/")
Dim content As String
content = System.Text.Encoding.UTF8.GetString(buffer)
Response.Write(Server.HtmlEncode(content))

CFML
<CFHTTP URL="http://www.macromedia.com/" METHOD="GET">
<CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT>



woogia

职务:普通成员
等级:1
金币:0.0
发贴:202
#62005/10/25 22:54:40
这是从 Macromedia 网站上转来的.
虽然 Macromedia 合 ADOBE 合并(在 Macromedia.com 及 Adobe.com 网站上均有信息)了, 但是, 估计新公司会继续发扬 Macromedia 在服务器上的优势.

我暂时还没有接触 ColdFusion,但个人认为:从设计和快速开发上讲,ColdFusion 肯定有他自己的优势.否则它早就消失了.
但是,从团队开发、项目管理、扩展性等角度考虑,微软的 .net 套件也是有他的优势的。

马上就抽时间学一学 ColdFusion.
呵呵。