asp+sqlserver2000开发聊天室是遇到数据库连接问题

rainmf 2003-08-19 03:08:29
ADO方式连接数据库,失败,语句如下,请问问题何在,高手指教!!!在线等待
dim conn,rs,sql,connstr
connstr="driver={SQL Server};server=mycomputer;uid=sa;pwd=1;database=mychat;"
set conn=Server.CreateObject("ADODB.Connection")
conn.open connstr
set rs=Server.createobject("adodb.recordset")

sql="select * from userinfo where userid='aa' "
rs.open sql,conn
if rs.eof then
response.write rs("password")
else
response.write "<br>no this man "
end if
rs.close
set rs=nothing
conn.close
set conn=nothing

结果数据库中明明有userid=aa的记录也输出"no this man ".我怀疑是连接问题.有人能解吗???
...全文
39 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
CrazyFor 2003-08-19
  • 打赏
  • 举报
回复
TRY:
dim conn,rs,sql,connstr
connstr="driver={SQL Server};server=mycomputer;uid=sa;pwd=1;database=mychat;"
set conn=Server.CreateObject("ADODB.Connection")
conn.open connstr
set rs=Server.createobject("adodb.recordset")

sql="select * from userinfo where userid='aa' "
rs.open sql,conn
if not rs.eof then
response.write rs("password")
else
response.write "<br>no this man "
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
zjcxc 元老 2003-08-19
  • 打赏
  • 举报
回复
判断写反了.

dim conn,rs,sql,connstr
connstr="driver={SQL Server};server=mycomputer;uid=sa;pwd=1;database=mychat;"
set conn=Server.CreateObject("ADODB.Connection")
conn.open connstr
set rs=Server.createobject("adodb.recordset")

sql="select * from userinfo where userid='aa' "
rs.open sql,conn
if rs.eof then '没有记录是为真
response.write "<br>no this man "
else
response.write rs("password")
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
dafu71 2003-08-19
  • 打赏
  • 举报
回复
if rs.eof then
response.write "<br>no this man "
else
response.write rs("password")
end if

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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