当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 一个功能完善的专栏管理的程序->这是asp.net的第二个应用(三)

ASP.NET
如何在ASP.NET中使用SmtpMail发送邮件
在VB.NET中利用Split和Replace函数计算字数
Attribute应用:简化ANF自定义控件初始化过程
ASP.NET 2.0移动开发入门之使用样式
ASP.NET 2.0中使用OWC生成图表
ASP.NET 2.0中控件的简单异步回调
一个无法捕获ADO.NET Dataset的内存错误
深入解读ADO.NET2.0的十大最新特性
.Net平台下的分布式缓存设计
ASP.NET全局异常处理浅析
ASP.NET 2.0中文验证码的实现
浅析.NET平台编程语言的未来走向
.net 框架程序设计收藏
使用ASP.NET MVC Futures 中的异步Action
详解.NET中的XmlReader与XmlWriter
关于.NET中的Server push技术
asp.net页面执行机制
对比JSP和ASP.NET的存储过程
.NET 4.0不会包含System.Shell.CommandLine
ASP.NET十个有效性能优化的方法

ASP.NET 中的 一个功能完善的专栏管理的程序->这是asp.net的第二个应用(三)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 186 ::
收藏到网摘: n/a

http://www.asp888.net 豆腐技术站

刚才说了一些题外话,现在我们来看看我们如何将在add.aspx中输入的数据保存在sql server中
<!--#include file="func.aspx"-->
<%
dim conn as SQLConnection
dim sqlRead as SQLDataReader
dim sqlCmd as SQLCommand
'这样我们通过 func.aspx 文件的使用,对连接代码等等很多通用的程序进行了同意的管理和调用
conn=GetConn()
dim strUserName as string
dim strPass as string
dim strSQL as string
strUserName=request.form("txtUserid")
strPass=request.form("txtPass")
strSQL="select UserPassword from lanmuuser where username='" & replaceSql(strUserName) & "'"

sqlCmd=new SQLCommand(strSQL,conn)
sqlCmd.ActiveConnection.Open()
sqlCmd.Execute(sqlRead)
sqlCmd.ActiveConnection.Close()
'这个部分是对 添加文章的用户 进行 限制和管理
'在演示的版本中,这段代码是 屏蔽起来的,如果我们需要对 用户进行限制
'简单的作个lanmuuser 的 table 就可以了
if not sqlRead.Read() then
response.Write("这个用户不存在")
response.end
end if
if sqlRead(0)<>strPass then
'密码不正确
response.Write("密码不正确")
response.end
end if
'校验合法
dim strClassid as string
strClassid=request.form("selClass")
dim strTitle as string
strTitle=request.form("txtTitle")
dim strContent as string
strContent=request.form("txtContent")
dim strSelFrom as string
strSelFrom=request.form("selFrom")
strSQL="insert into lanmu(classid,title,content,dtime,userid,IsUse,viewnum,selFrom)values("
strSQL=strSQL & "" & strClassId & ",'" & replaceSql(strTitle) & "','" & replaceSql(strContent) & "',"
strSQL=strSQL & "getdate(),'" & replaceSql(strUserName) & "','0',0,'" & strSelFrom & "')"

sqlCmd=new SQLCommand(strSQL,conn)
sqlCmd.ActiveConnection.Open()
'response.write(strSQL)
sqlCmd.execute
response.write("恭喜,恭喜,您的文章已经成功的添加到了 文章数据库,管理员会在下次更新的时候检查你的文章,如果没有什么问题的话,您的文章将会很快出现在我们的栏目中")
response.end
%>

呵呵,是不是很简单?:)别高兴的太早,这个只是把数据存入了数据库,下面我们就会在后面的文章中,看到我们
是怎么样把数据显示出来的,毕竟,这个才识主要的:)