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

ASP.NET
.net开发实例:绑定到ADO.NET数据源
vb.net中应用 ArrayList 实例
用.net 处理xmlHttp发送异步请求
编写ASP.NET应用程序的十大技巧
完全不使用配置文件构建和使用WCF服务
VB.net2008精彩实例,窗体应用技巧
VB.Net实现Web Service的基础
实用技巧:.Net框架类库中定时器类的使用
ASP.NET MVC:实现我们自己的视图引擎
基于ASP.NET MVC框架开发Web论坛应用程序
用VB.net2008打造你的影音播放器
如何使用.NET实现断点续传功能
如何用.NET技术在线生成网站LOGO
挖掘ADO.NET Entity框架的性能
编写ASP.NET应用程序的十大技巧 (1)
Asp.NET大文件上传开发总结集合
.net开发:如何为程式码加上行号
ASP.NET 中整合JavaScript技巧
浅谈.NET中加密和解密的实现方法
浅析ASP.NET 2.0 Client Callback

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 99 ::
收藏到网摘: 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
%>

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