紧急求救各位大侠!小弟我以下语句有什么有关问题?应该怎么修改
紧急求救各位大侠!我以下语句有什么问题?应该如何修改?
请教各位大侠:
Text10.Text = "xcdj " + Format(Now, "yyyymmdd ") + "0000 "
执行 adocon.Execute "insert into xcdjk values( " & Text10 & ", ' " & Text2 & " ', ' " & Text1 & " ', ' " & Text3 & " ', ' " & Text4 & " ', ' " & Text5 & " ', ' " & Text6 & " ', ' " & Text7 & " ', ' " & Text8 & " ', ' " & Text9 & " ') "
出现如下错误:
实时错误 '-2147217900(80040e14) '
[Microsoft][ODBC SQL Server Driver][SQL Server]在此上下文中不允许使用‘scdj200705120000’。此处只允许使用常量、表达式或变量。不允许使用列名。
如果我前面那条语句不带“xcdj”,下面数据库写入就没有任何问题!但是“xcdj”不是列名阿,我text10需要插入数据库噶字段是char型的,16位长,手工输入该号入去没有任何问题,但是程序输入却不行。请问为什么呢??
有什么办法解决?
------解决方案--------------------
adocon.Execute "insert into xcdjk values( ' " & Text10 & " ', ' " & Text2 & " ', ' " & Text1 & " ', ' " & Text3 & " ', ' " & Text4 & " ', ' " & Text5 & " ', ' " & Text6 & " ', ' " & Text7 & " ', ' " & Text8 & " ', ' " & Text9 & " ') "
加上单引号,因为你这里是字符串。前面加2323就是纯数字,则可以省略单引号(不过既然是char型,还是加上单引号比较好)。
请教各位大侠:
Text10.Text = "xcdj " + Format(Now, "yyyymmdd ") + "0000 "
执行 adocon.Execute "insert into xcdjk values( " & Text10 & ", ' " & Text2 & " ', ' " & Text1 & " ', ' " & Text3 & " ', ' " & Text4 & " ', ' " & Text5 & " ', ' " & Text6 & " ', ' " & Text7 & " ', ' " & Text8 & " ', ' " & Text9 & " ') "
出现如下错误:
实时错误 '-2147217900(80040e14) '
[Microsoft][ODBC SQL Server Driver][SQL Server]在此上下文中不允许使用‘scdj200705120000’。此处只允许使用常量、表达式或变量。不允许使用列名。
如果我前面那条语句不带“xcdj”,下面数据库写入就没有任何问题!但是“xcdj”不是列名阿,我text10需要插入数据库噶字段是char型的,16位长,手工输入该号入去没有任何问题,但是程序输入却不行。请问为什么呢??
有什么办法解决?
------解决方案--------------------
adocon.Execute "insert into xcdjk values( ' " & Text10 & " ', ' " & Text2 & " ', ' " & Text1 & " ', ' " & Text3 & " ', ' " & Text4 & " ', ' " & Text5 & " ', ' " & Text6 & " ', ' " & Text7 & " ', ' " & Text8 & " ', ' " & Text9 & " ') "
加上单引号,因为你这里是字符串。前面加2323就是纯数字,则可以省略单引号(不过既然是char型,还是加上单引号比较好)。