insert into语句的语法错误

来源:百度知道 编辑:UC知道 时间:2024/09/24 11:20:28
cpu=Request("select")
grade=Request("select3")
department=Request("select4")
timepd=Request("select2")
money=Request("select5")
needs=Request("select6")
houhui=Request("select7")
thing=Request("select8")
timegj=Request("select9")
gfs=Request("select10")

sql="insert into stu(cpu,grade,department,timepd,money,needs,houhui,thing,timegj,gfs) values('" & cpu & "','" & grade & "','" & department & "','" & timepd & "','" & money & "','" & needs & "','" & houhui & "','" & thing & "','" & timegj & "','" & gfs & "')"
conn.execute sql

我也试过,插入语句格式是正确的(因为是从另外一个能运行的程序拷过来的),在放在我的文件中就说“INSERT INTO 语句的语法错误”
但后来解决了,方法是将表和字段名都加上中括号,就是改成这样:
sql="insert into [stu]([cpu],[grade,department],[timepd],[money],[needs],[houhui],[thing],[timegj],[gfs]) values('" & cpu & "','" & grade & "','" & department & "','" & timepd & "','" & money & "','" & needs & "','" & houhui & "','" & thing & "','" & timegj & "','" & gfs & "')"
我用的是c#

now