asp+版本简单的留言板的制作(二)
点击次数:26 次 发布日期:2008-11-26 17:32:40 作者:源代码网
|
/* 豆腐制作,都是精品 http://www.asp888.net 豆腐技术站 如转载,请保留版权信息 */ 在留言的录入界面完成后,自然要准备做留言内容的录入了。这个其中一个很关键的地方就是如何将我们在config.web 的内容读取出来,我用了下面的几条语句 Dim Cfg as HashTable Cfg = Context.GetConfig("appsettings") Conn = New SQLConnection(cfg("Conn")) 这样就得到了我们在config.web 中设定的 连接串,程序如下 <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQL" %> <script runat="server" language="VB"> Sub Page_Load(Src As Object, E As EventArgs) Dim conn As SQLConnection Dim Cfg as HashTable Cfg = Context.GetConfig("appsettings") Conn = New SQLConnection(cfg("Conn")) dim strSQL as string dim strNickName as string dim strMail as string dim strTitle as string dim strContent as string dim strIPAddr as string strNickName=replace(request.form("txtName"),""","""") strEmail=replace(request.form("txtMail"),""","""") strTitle=replace(request.form("txtTitle"),""","""") strContent=replace(request.form("txtContent"),""","""") strIPAddr=Request.ServerVariables ("REMOTE_ADDR") "用户IP地址 strSQL="insert into msgBoard(nickname,email,ipAddr,msgTime,msgTitle,msgContent)values(" strSQL=strSQL & """ & strNickName & "","" & strEMail & "","" & strIPAddr & "",getdate(),"" & strTitle & "","" & strContent & "")" response.write(strSQL) Dim Cmd As SQLCommand Cmd = New SQLCommand(strSQL,conn) Cmd.ActiveConnection.Open() Cmd.Execute() Cmd.ActiveConnection.Close() Response.Redirect("showmsg.aspx") end sub </script> 大家其实一看,就知道这段程序其实和asp的程序没有什么区别嘛,对了,跟着MS 的唯一的好处就是 他们在升级的时候总是对他们的以前的系统进行了很好的 兼容,除了因为引用了 ado.net 而使得数据库的操作 改变的比较多以外,其他的代码基本上都没有什么大的改变,糟糕 说道这里 就说错了一句话,不是没有什么大的改动,变化还是很大的,只不过对以前兼容了,我们这样的简单的应用,似乎也不会牵扯到什么复杂的改变的:) 源代码网供稿. |
