主题:插入问题
我在做注册页面时,把数据插进数据库是可以,为什么第一个就不可以插进去啊?
在注册时,没填数据就出现类型不匹配,这怎么解决啊?
下面是我的代码,请各位帮忙解决下:谢谢了
Dim UserNumber,Password,RealName,Phone,Email,Address,Notice
UserNumber=Request.Form("name")
Password=Request.Form("password")
RealName=Request.Form("realname")
Phone=Request.Form("phone")
Email=Request.Form("email")
Address=Request.Form("address")
Notice=Request.Form("notice")
dim conn
set conn=server.createobject("adodb.Connection")
conn.connectionString="Dbq=C:\Inetpub\wwwroot\canting.mdb;Driver={Microsoft Access Driver (*.mdb)}"
conn.mode=0
conn.open
dim comm
set comm=server.CreateObject("Adodb.Command")
comm.ActiveConnection=conn
comm.Commandtype=1
dim sqlstr
sqlstr="Select * from zhuce where name='"&UserNumber&"'"
comm.commandtext=sqlstr
set dbrs=comm.execute
if dbrs.eof and dbrs.bof then
sqlstr="insert into zhuce(name,password,realname,phone,email,address,notice) values"
sqlstr=sqlstr &"('"&name&"','"&password&"','"&realname&"','"&phone&"','"&email&"','"&address&"','"¬ice&"')"
comm.commandtext=sqlstr
comm.execute
response.write("添加成功!")
else
response.Redirect("register.asp")
end if
conn.close
set conn=Nothing
在注册时,没填数据就出现类型不匹配,这怎么解决啊?
下面是我的代码,请各位帮忙解决下:谢谢了
Dim UserNumber,Password,RealName,Phone,Email,Address,Notice
UserNumber=Request.Form("name")
Password=Request.Form("password")
RealName=Request.Form("realname")
Phone=Request.Form("phone")
Email=Request.Form("email")
Address=Request.Form("address")
Notice=Request.Form("notice")
dim conn
set conn=server.createobject("adodb.Connection")
conn.connectionString="Dbq=C:\Inetpub\wwwroot\canting.mdb;Driver={Microsoft Access Driver (*.mdb)}"
conn.mode=0
conn.open
dim comm
set comm=server.CreateObject("Adodb.Command")
comm.ActiveConnection=conn
comm.Commandtype=1
dim sqlstr
sqlstr="Select * from zhuce where name='"&UserNumber&"'"
comm.commandtext=sqlstr
set dbrs=comm.execute
if dbrs.eof and dbrs.bof then
sqlstr="insert into zhuce(name,password,realname,phone,email,address,notice) values"
sqlstr=sqlstr &"('"&name&"','"&password&"','"&realname&"','"&phone&"','"&email&"','"&address&"','"¬ice&"')"
comm.commandtext=sqlstr
comm.execute
response.write("添加成功!")
else
response.Redirect("register.asp")
end if
conn.close
set conn=Nothing