请高手帮忙看下这段asp代码哪里出错
来源:百度知道 编辑:UC知道 时间:2024/05/22 15:40:00
<%
set rs=server.createobject("adodb.recordset")
sql="select * from user1 where username='"&trim(request("username"))&"'"
rs.open sql,secondconn,3,3
if not rs.eof then
errmsg =errmsg+"<br><li>用户名"+trim(request("username"))+"已被别人 注册"
founderr=true
end if
rs.close
set rs=nothing
if trim(request("birthyear"))=" " then
birthyear=" "
else birthyear=trim(request("birthyear"))
end if
if trim(request("birthmonth"))=" " then
birthyear=" "
else birthmonth=trim(request("birthmonth"))
end if
if trim(request("birthday"))=" " th
sql="select * from user1 where username='"&trim(request("username"))&"'"
你可能原来学过JAVASCRIPT语言吧?先看一下语法吧!
呵呵,可能都没有看出来是什么原因,其实很多书上也是这样讲的。问题是现在很多的例子和专家们都不太注意一个细节。
我知道你看不出来。因为不仔细地看真不了解有这么一个细节的。
我们知道,在JAVASCRIPT等类似语言中,单双半角引号引起来表示一个字符串。这个无可厚非,但在VB和VBSCRIPT中有这样的规定吗?很多书上也是这样定义的。好像没有错。其实错就在这一句话上。
如果照某些书上的定义,这样是正确的话,那么有一个问题我不得不提醒一下:VB和VBSCRIPT语言中有这样一个明语规定:半角单引号是VB和VBSCRIPT中的一种注释方法!我想都不会不注意吧。这就是这句语句的错误了,也就是我为什么说是语法错误的原因了。
我几乎没用过if not rs.eof then .
我一般都是用if rs.eof and rs.bof then
来判断 无记录存在.
把前面那段代码换成下面那段试一下,我也不特别会,也在学习~
if founderr=false then
dim sqlCheckReg,rsCheckReg
sqlCheckReg="select * from [User] where Username & "'"
set rsCheckReg=server.createobject("adodb.recordset")
rsCheckReg.open sqlCheckReg,conn,3,3
if not(rsCheckReg.bof and rsCheckReg.eof) then
founderr=true
errmsg=errmsg & "