炎黄战史之魔舞洪荒:请问我的下列语句为何提示语法错误??

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/02 09:07:56
sql="insert into students(studentsID,nj,bj,name,xb,tuan,birthdate,photo,jh,jhtelephone,jhplace,father,fathertelephone,fatherwork,mother,mothertelephone,motherwork,homeaddress,telephone,jiangli,chufen,byschools,other,update) values('"& studentsID & "','"& nj &"','"& bj &"','"& name0 &"','"& xb &"','"& tuan &"','"& birthdate &"','"& photo &"','"& jh &"','"& jhtelephone &"','"& jhplace &"','"& father &"','"& fathertelephone &"','"& fatherwork &"','"& mother &"','"& mothertelephone &"','"& motherwork &"','"& homeaddress &"','"& telephone &"','"& jiangli &"','"& chufen &"','"& byschools &"','"& other &"','" & date() &"')"
conn.Execute(sql)
所有的字段名跟ACCESS库中的一致.
我的studentsID文本型,而且总提示37行语法有错误.原程序如下:
sql="insert into students(studentsID,nj,bj,name,xb,tuan,birthdate,photo,jh,jhtelephone,jhplace,father,fathertelephone,fatherwork,mother,mothertelephone,motherwork,homeaddress,telephone,jiangli,chufen,byschools,other,update) values('"& studentsID & "','"& nj &"','"& bj &"','"& name0 &"','"& xb &"','"& tuan &"','"& birthdate &"','"& photo &"','"& jh &"','"& jhtelephone &"','"& jhplace &"','"& father &"','"& fathertelephone &"','"& fatherwork &"','"& mother &"','"& mothertelephone &"','"& motherwork &"','"& homeaddress &"','"& telephone &"','"& jiangli &"','"& chufen &"','"& byschools &"','"& other &"','date())"
conn.Execute(sql) (此为37行)
conn.close
set conn=nothing

sql="insert into students(studentsID,nj,bj,name,xb,tuan,birthdate,photo,jh,jhtelephone,jhplace,father,fathertelephone,fatherwork,mother,mothertelephone,motherwork,homeaddress,telephone,jiangli,chufen,byschools,other,update) values("& studentsID & ",'"& nj &"','"& bj &"','"& name0 &"','"& xb &"','"& tuan &"','"& birthdate &"','"& photo &"','"& jh &"','"& jhtelephone &"','"& jhplace &"','"& father &"','"& fathertelephone &"','"& fatherwork &"','"& mother &"','"& mothertelephone &"','"& motherwork &"','"& homeaddress &"','"& telephone &"','"& jiangli &"','"& chufen &"','"& byschools &"','"& other &"',now())"
分析studentsID为 数字类型 所以不能在数字类型上加引号

studentsid如果是数字型的话应该是"&studentsid&"
access数据库日期型格式应该是#2006-06-21#这种
你这个错误应该是你的数据变量类型跟数据库字段类型不匹配

除了studentsID这个可能错误以外,我觉得主要是最后一个日期函数调用时不应该加单引号。"insert into ...,'"& other &"', date())"