asp注册信息进入不了数据库?

来源:百度知道 编辑:UC知道 时间:2024/06/05 15:38:25
<%
on error resume next
dim sql,rst
if request.QueryString("act")="reg" then
if request.Form("user")="" or request.Form("code")="" then
msgboxU "用户名和密码要填写"
else
set rst=server.CreateObject("adodb.recordset")
sql="select count(*) as recnum from zj_user where user='"&request.Form("user")&"'"
rst.open sql,conn,1,1
if rst("recnum")>0 then
msgboxU"该用户存在"
else
sql="insert into zj_user(user,code,name,sex,age) values('"&request.Form("user")&","&request.Form("code")&","&request.Form("name")&","&request.Form("sex")&","&request.Form("age")&"')"
conn.execute sql
set myerrors=conn.errors
if myerrors.count=0 then

字符串进入数据库需要用单引号罩起来
sql="insert into 数据表(user,name)values('user值','name值')"

另外,数字值就不要用单引号了

引号问题,字符型数据要引号")&",’"&request.Form("code")&"’,"&

rst.open sql,conn,1,1改为rst.open sql,conn,1,3;rst.open sql,conn,1,1为只读,只能查询,不能对数据库操作,该为1,3就可以了