动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

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

作者来源: 
阅读 4986 人次 , 2000-12-10 

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

  

 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:asp+版本简单的留言板的制作(三)
· 下一篇:asp+版本简单的留言板的制作(一)
· .NET之ASP Web Application快速入门(3)
· 十一、JSP及语法概要
· 全面剖析VB.NET(5)
· MyFirstServlet
· 微软的远程处理框架.NET Remoting - 1


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077