请看一下

Leop 2000-09-14 10:12:00
如下一段代码
strSQL = "Select * From Info Where Username='" & Username & "'"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn, 0, 1

If objRS.RecordCount > 0 Then '这一句始终是真
Session("errMessage") = "您填的用户名已存在,请用别的用户名!"
Response.Redirect "step1.asp"
End If

objRS.Close
objConn.Close
objRS = Nothing
objConn = Nothing
Response.Redirect "step2.asp"

始终执行
If objRS.RecordCount > 0 Then
Session("errMessage") = "您填的用户名已存在,请用别的用户名!"
Response.Redirect "step1.asp"
End If
这一段,为什么?
我用的是Access 97 & Win2k & IIS5.0
...全文
170 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
蝈蝈俊 2000-09-15
  • 打赏
  • 举报
回复
在 objRS.Open strSQL, objConn, 0, 1 时
不支持RecordCount 属性
试一试 objRS.Open strSQL, objConn, 3
Molly 2000-09-15
  • 打赏
  • 举报
回复
换换游标类型,RecordCount只在CursorType=1or3中可用
flyby 2000-09-15
  • 打赏
  • 举报
回复
huntout的回答很对!
huntout 2000-09-15
  • 打赏
  • 举报
回复
If not objRS.eof Then
Session("errMessage") = "您填的用户名已存在,请用别的用户名!"
Response.Redirect "step1.asp"
End If
Leop 2000-09-15
  • 打赏
  • 举报
回复
谢谢各位,这次我请大家吃大锅饭:)
subzero 2000-09-15
  • 打赏
  • 举报
回复
你数据库里面是不是有数据呀
要没有的话用这个
if objRS.bof then
.....
end if
Tyro 2000-09-15
  • 打赏
  • 举报
回复
你用
If not(objRS.eof and objRS.bof)Then
Session("errMessage") = "您填的用户名已存在,请用别的用户名!"
Response.Redirect "step1.asp"
End If
试试吧!我记得好像是access必须要movelast才能获得正确的recordcount值

28,390

社区成员

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

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