[图5-15选择Insert Record]
[图5-16数据添加设定]
让我们看看添加的代码:
< MM:Insert
runat="server"
CommandText='< %# "INSERT INTO COMMENTS (COMMENTS, EMAIL, FIRST_NAME, LAST_NAME, TELEPHONE) VALUES (?, ?, ?, ?, ?)" % >'
ConnectionString='< %# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_location") % >'
DatabaseType='< %# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_location") % >'
Expression='< %# Request.Form("MM_insert") = "form1" % >'
CreateDataSet="false"
SuccessURL='< %# "index.htm" % >'
FailureURL='< %# "reg.aspx" % >'
Debug="true"
>
< Parameters >
< Parameter Name="@COMMENTS" Value='< %# IIf((Request.Form("Comments") < > Nothing), Request.Form("Comments"), "") % >' Type="WChar" / >
< Parameter Name="@EMAIL" Value='< %# IIf((Request.Form("email") < > Nothing), Request.Form("email"), "") % >' Type="WChar" / >
< Parameter Name="@FIRST_NAME" Value='< %# IIf((Request.Form("first") < > Nothing), Request.Form("first"), "") % >' Type="WChar" / >
< Parameter Name="@LAST_NAME" Value='< %# IIf((Request.Form("Lastname") < > Nothing), Request.Form("Lastname"), "") % >' Type="WChar" / >
< Parameter Name="@TELEPHONE" Value='< %# IIf((Request.Form("telephone") < > Nothing), Request.Form("telephone"), "") % >' Type="WChar" / >
< /Parameters >
< /MM:Insert >
MM:Insert是Dreamweaver用于添加数据库的标签,Parameter就是用于指定参数的数值。
前面的代码就是用于指定数据库链接以及添加成功后跳转到的页面,添加失败显示错误信息,还有相关联的表格。
这些都是MacroMedia自己开发的,需要Macromedia的一些组件支持,与现在网上很多ASP.net的标准代码格式不同。请大家参照代码的时候不要根据此代码而错误理解ASP.net的标准代码格式。标准代码格式大家可以参看www.gotdotnet.com。如果大家想写标准的代码,可以使用WebMatrix,下载地址: http://www.asp.net/webmatrix/download.aspx?tabindex=4
本篇文章来源于 麦客教程网(学吧频道) 原文链接:http://x8.maicoo.com/tech/dreamweaver/4671.html
(编辑: