初学菜鸟,数据库(sql)连接的问题,请大侠进来看看

taishan0263 2005-11-22 09:24:06
dim strName
dim strPwd
dim strQx
strName = Request.form("text1")
strPwd = Request.form("pwd")
strQx = Request.form("qx")

sql = "select yh_xm,yh_mm,yh_qx from yonghu where yh_xm='text1' & yh_mm='pwd'"'就是这句出错
dim conn'连接数据库
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=192.168.0.1;UID=aa;PWD=aa;DATABASE=kfgl"

set rs=server.createobject("adodb.recordset") '建立记录集

rs.open sql.conn'不知这句是什么意思??

if rs.EOF then
response.write "错误的用户名及密码"
rs.close
set rs = nothing
conn.close
set conn = nothing
response.end
end if

if not(rs("yh_mm")=pwd) then
response.write "错误的用户名及密码"
rs.close
set rs = nothing
conn.close
set conn = nothing
response.end
end if

'错误提示如下:

'Microsoft VBScript 运行时错误 错误 '800a01a8'

'缺少对象: 'rs'
...全文
152 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lnboy1003 2005-11-22
  • 打赏
  • 举报
回复
应该是
if rs.EOF then
response.write "错误的用户名及密码"
rs.close
set rs = nothing
conn.close
set conn = nothing
response.end
else
if not(rs("yh_mm")=pwd) then
response.write "错误的用户名及密码"
rs.close
set rs = nothing
conn.close
set conn = nothing
response.end
end if

end if

lnboy1003 2005-11-22
  • 打赏
  • 举报
回复
错误是这样的如果你没有找到你输入的用户名那么数据集已经关闭,那么你下边又判断if not(rs("yh_mm")=pwd) then当然找不到数据集rs啊
taishan0263 2005-11-22
  • 打赏
  • 举报
回复
楼上的大侠,还是出错啊
真是晕了
huguang 2005-11-22
  • 打赏
  • 举报
回复
rs.open sql.conn'不知这句是什么意思??

这里是打开纪录集,光建立了不行,当然还要打开,这里的sql就是你出错的那个字符串
我一般写成
rs.open sql,conn,0,1
freetaiger 2005-11-22
  • 打赏
  • 举报
回复
sql = "select yh_xm,yh_mm,yh_qx from yonghu where yh_xm='"& strName &"' and yh_mm='"& strPwd &"'"

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧