兄弟门!!!救急啊!!INSERT INTO 语句的语法错误!!

zhongxianyun 2006-08-11 11:10:52

mySQL="insert into register (UserID,PassWord,UserName,Birth,Diploma,TelPhone,CellPhone,"
mySQL=mySQL+"IDCard,Province,City,Gender,PassQuestion,PassAnswer,HomePage,Address,PostCode)"
mySQL=mySQL+" values ('" & myID & "','" & myPass & "','" & myName & "',#"
mySQL=mySQL + myBirth & "#,'" & myDip & "','" & myTel & "','" & myCell
mySQL=mySQL + "','" & myIDCard & "','" & myPro & "','" & myCity & "','" & myGender
mySQL=mySQL + "','" & myQues & "','" & myAns & "','" & myHomePage & "','" & myAdd
mySQL=mySQL + "','" & myPost & "')"

总是提示:
Microsoft JET Database Engine (0x80040E14)
INSERT INTO 语句的语法错误。
/web/9/addRecord.asp, 第 52 行
...全文
147 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhongxianyun 2006-08-11
  • 打赏
  • 举报
回复
除了 UserID,PassWord,UserName,Birth,Gender,PassQuestion,PassAnswer
以外都允许空
zhenmeiyisi 2006-08-11
  • 打赏
  • 举报
回复
还不可以吗? 提示什么错误?

Diploma 允许空吗?
zhongxianyun 2006-08-11
  • 打赏
  • 举报
回复
注册部分代码如下:

Dim ConnStr,myConn,mySQL
dim myID,myName,myPass,myBirth,myDip,myTel,myCell,myIDCard
dim myPro,myCity,myGender,myQues,myAns,myHomePage,myAdd,myPost
ConnStr="Provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("../9/masterasp.mdb")
Set myConn=Server.CreateObject ("ADODB.Connection")
Myconn. ConnectionString=ConnStr
myConn.open '直接打开数据库连接



myID=request.form("login") '用户名
myName=request.form("realname") '真实姓名
myPass=request.form("passwd") '密码
myBirth=request.form("birth") '生日
myDip=request.form("diploma") '学历
myTel=request.form("telphone") '电话
myCell=request.form("cellphone") '手机
myIDCard=request.form("idCard") '身份证
myPro=request.form("state") '省份
myCity=request.form("city") '城市
myGender=request.form("gender") '性别
myQues=request.form("question") '提示问题
myAns=request.form("answer") '提示答案
myHomePage=request.form("homepage") '主页
myAdd=request.form("address") '地址
myPost=request.form("postcode") '邮政编码

'查询该ID是否存在
mySQL="select * from register where UserID=" & myID & ""
set myRes=myConn.execute(mySQL)

if myRes.bof and myRes.eof then

'定义一个Insert的SQL语句,向maserasp.mdb的register数据库表插入一条记录
mySQL="insert into register (UserID,PassWord,UserName,Birth,Diploma,TelPhone,CellPhone,"
mySQL=mySQL+"IDCard,Province,City,Gender,PassQuestion,PassAnswer,HomePage,Address,PostCode)"
mySQL=mySQL+" values (" & myID & ",'" & myPass & "','" & myName & "',#"
mySQL=mySQL + myBirth & "#,'" & myDip & "','" & myTel & "','" & myCell
mySQL=mySQL + "','" & myIDCard & "','" & myPro & "','" & myCity & "','" & myGender
mySQL=mySQL + "','" & myQues & "','" & myAns & "','" & myHomePage & "','" & myAdd
mySQL=mySQL + "','" & myPost & "')"
response.write mysql
response.end

myConn.Execute mySQL

response.write "<br>你注册成功,请回到登录页面!"
%>
<a href="../chap10/access/login.asp">单击这里链接到登录页面 </a>

<%
else

response.write "该帐号已经存在!"

%>
<!-- #include file="register.asp" -->
<%
end if

myConn.close
set myConn=nothing
zhongxianyun 2006-08-11
  • 打赏
  • 举报
回复
我用的是ACCESS 数据库
ID 是int型
改了执行结果如下:

insert into register (UserID,PassWord,UserName,Birth,Diploma,TelPhone,CellPhone,IDCard,Province,City,Gender,PassQuestion,PassAnswer,HomePage,Address,PostCode) values (123456,'123456','张三',#1981-1-1#,'','1234567','13659661347','450722198410191516','广东','广州','男','1234567','123456','www.163.com','广州','450006')
  • 打赏
  • 举报
回复
ac的话'#...吧,有点儿不记得了,要不就是你写的那样,记不清楚了,试验一下就可以了
  • 打赏
  • 举报
回复
1981-1-1

你是什么数据库??sql server还是access?sql server应该用''括起来
zhenmeiyisi 2006-08-11
  • 打赏
  • 举报
回复
UserID 如果是int ? 去掉 '' '123456'===123456
zhongxianyun 2006-08-11
  • 打赏
  • 举报
回复
用
response.write mysql
response.end
显示如下:

insert into register (UserID,PassWord,UserName,Birth,Diploma,TelPhone,CellPhone,IDCard,Province,City,Gender,PassQuestion,PassAnswer,HomePage,Address,PostCode) values ('123456','123456','张三',#1981-1-1#,'','1234567','13659661347','450722198410191516','广东','广州','男','1234567','123456','www.163.com','广州','450006')
我是丁学 2006-08-11
  • 打赏
  • 举报
回复
先把执行数据库操作的那句注释掉,把你的sql语句输出一下 response.write mySQL
看输出到屏幕上的语句是什么,把这个语句在查询分析器里执行,你会发现这个语句哪儿错了
  • 打赏
  • 举报
回复
response.write mysql
response.end

28,402

社区成员

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

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