Dim now As Date
now = Date
conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values_
(" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower_
& "'," & now & ")"
应该是这样!?
now = Date
conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values_
(" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower_
& "'," & now & ")"
应该是这样!?
(" & CStr(CInt(Id)) & "," & CStr(CInt(Quantity)) & ",'" & Borrower & "','" & Format(now,"mmmm dd yyyy" & "')"
时间型的数据要先转化
换个变量就可以了,比如 Today.
如果你的数据库是SQL 请用INSERT
(" & CStr(CInt(Id)) & "," & CStr(CInt(Quantity)) & ",'" & Borrower & "',#" & now & "#)"
(" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower & "',#" & Format(now,"yyyy/mm/dd) & "#)"
conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values
(" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower & "',#" & Format(now,"yyyy/mm/dd") & "#)"
用括号括起来 或 改用别的字段名
mynow = Date
conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values
(" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower
& "','" & mynow & "')"
Dim now As Date
now = Date
conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values
('" & CInt(Id) & "','" & CInt(Quantity) & "','" & Borrower
& "','" & now & "')"
2。时间格式应用#符号
"2。时间格式应用#符号 "
你试试 #2001-10-1# 看会不会报错
如果这种问题的话不会报错!只会返回空纪录集!
谢谢大家,特别是 T2(無藥可救) 先生、haitaoyu(i老虎u)等。
事情是这样的:
1. 不能用 User,因为 User 是sql的保留字;
2. 不能用Date,因为 Date 是Vb的保留字。
以后大家一起注意下不要用保留字啊~~~~~~~~~~~~~要不就会像我这样惨!
谢谢大家的支持。