首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ASP MYSQL错误,SQL语句末尾缺少分号(;)。到处都试过

ASP MYSQL错误,SQL语句末尾缺少分号(;)。到处都试过
EN

Stack Overflow用户
提问于 2015-01-08 12:44:41
回答 1查看 297关注 0票数 0

这是我的代码,我需要添加更多的行,我只用了两行就进行了测试

代码语言:javascript
运行
复制
' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ")"
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

我一直收到“在SQL语句末尾缺少分号(;)”的错误信息。我添加了分号,结果得到"expected of statement“

下面我将发布我尝试使用分号的所有方法。我不知道还能做什么。

代码语言:javascript
运行
复制
' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ");"
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ")";
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ";)"
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ")"
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp");

' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ")";"
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ");";
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

和我受挫的审判:

代码语言:javascript
运行
复制
' insert into db
mySQL="INSERT INTO scheduleparts (scheduleid, locationid, dayid, partid, stime, guys, position) VALUES (" & pschedid & ", " & pidlocation & ",1,1,'" &ps11& "', " & pg11 & ", " & pp11 & "),(" & pschedid & ", " & pidlocation & ",1,2,'" &ps12& "', " & pg12 & ", " & pp12 & ")";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call updateDatabase(mySQL, rstemp, "addscheduleform4.asp")

每种方法每次都会失败。我要么缺少分号,要么语句结束

EN

回答 1

Stack Overflow用户

发布于 2015-03-20 08:27:01

当插入到MYSQL中时,需要用单引号将要插入的值括起来。尝试在用双引号括起变量名前后添加它们,例如

代码语言:javascript
运行
复制
('" & pschedid & "',

如果单引号不起作用,试着用反引号。MYSQL对它的引号有点奇怪,如果你用单引号在Word中输入查询,然后复制粘贴,它不会起作用,但如果你在记事本上做,它就会起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27833100

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档