1

我正在尝试在表中插入一个条目,但服务器这样说

column "Date" is of type date but expression is of type integer at character 131

这是我也可以显示 VB.net 的 SQL 语句,但它是一个可怕的混乱。

INSERT INTO "Inventory_chemicalrecord"("Barcode","Action","Name_id","Building","Qty","Date") VALUES ('IEN0001','ADD',1,'Marcus',1,2013-07-10);

这是我传递的字符串

mySQLString = "INSERT INTO "&Chr(34)&"Inventory_chemicalrecord"&Chr(34)&"("&Chr(34)&"Barcode"&Chr(34)& ","&Chr(34)&"Action"&Chr(34)& ","&Chr(34)&"Name_id"&Chr(34)& ","&Chr(34)&"Building"&Chr(34)& "," &Chr(34)&"Qty"&Chr(34)& ","&Chr(34)&"Date"&Chr(34)& ") VALUES ("& code & "," &Chr(39)& Action &Chr(39) & "," & Name_id & "," & Building & ","& OriginalQty & "," & CurDate & ");"

抱歉,这是我发现的唯一方法,如果这是错误的方法,请通知我。

我试过了

Chr(39)&CurDate&Chr(39)
"'"&CurDate&"'"

甚至设置

CurDate = Chr(39)&CurDate&CurDate(39)

我不断收到预期的 EOF 并且 Type & 与 String 不匹配有没有更好的方法来做到这一点?

4

1 回答 1

1

错误信息非常清楚。

日期需要用引号括起来:'2013-07-10'

INSERT INTO "Inventory_chemicalrecord"("Barcode","Action","Name_id","Building","Qty","Date") VALUES ('IEN0001','ADD',1,'Marcus',1,2013-07-10);

应该

INSERT INTO "Inventory_chemicalrecord"("Barcode","Action","Name_id","Building","Qty","Date") VALUES ('IEN0001','ADD',1,'Marcus',1,'2013-07-10');
于 2013-07-10T21:58:28.160 回答