制作内幕 游戏 网站 图标 | 理论 图标在线制作 | 看图软件 访谈活动 | 教程 技术 万年历
当前位置:首页>CG 教 程>网站开发>ASP.NET>

相关文章

推荐文章

     

热门文章

asp+版本简单的留言板的制作(二)

作者:CG谷 出处: 发布时间:2006-07-11 字体: [ ]

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 而使得数据库的操作 改变的比较多以外,其他的
代码基本上都没有什么大的改变,糟糕 说道这里 就说错了一句话,不是没有什么大的改动,变化还是很大的,只不过对
以前兼容了,我们这样的简单的应用,似乎也不会牵扯到什么复杂的改变的:)


↑返回顶部   打印本页   关闭窗口↓  
收藏本文到:天极网摘 新浪VIVI 和讯网摘 博彩中心 365Key网摘 poco网摘 狐摘
亿友响享Yeeyoo igooi-it网摘 5seek网摘 I2Key 我摘网摘 天下图摘 YouNote 百特门
用户名: 新注册) 密码: 匿名评论 [所有评论]
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
设计服务 | 广告投放 | 友情链接 | 关于本站 | 联系我们 | 版权声明 | 设为首页 | 加入收藏