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

ASP
使用ASP中的VB ActiveX.dll文件
用ADO的COMMAND对象实现对WEB数据库动态数据查询的方法
在ASP中使用简单Java类
借助组件使用asp连接informix全方案
用ADSI编程实现IIS中建立虚拟目录
不刷新页面筛选数据库中的数据
使用ISAPI过滤器增强IIS的功能
利用J2ME与ASP建立数据库连接
用通ASP直接获取用户真实IP地址
用ASP编写计数器的优化方法
通过ASP远程注册自己的组件
检测IP地址是否真正合法的函数
用asp做access的远程接口
错误80004005信息处理方法
ASP学习:urldecode 方法补遗
在HTML页面中实现点击数统计
ASP字数计算函数
用ASP随机生成文件名的函数
单页面判断浏览器是否接受 Cookies
存储过程介绍及asp+存储过程的使用

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


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

  一个功能完善的专栏管理的程序->这是asp.net的第二个应用(三)
/*
豆腐制作,都是精品
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
%>

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