本文介绍了在vb.net和ms访问中的insert语句中获取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
下面是我的代码快照,我想在Inwards表中插入值,我已经存储了所有变量,如命令,con在模块中。我没有收到任何错误,但是当我调试时,我得到异常消息INSERT INTO语句中的语法错误。 PLZ帮助我,
Hi
below is my code snapshot where i wanted to insert values in Inwards table, I have stores all variables like command,con in module. I am not getting any error but when i debugged then i got exception message as "Syntax error in INSERT INTO statement." plz help me,
str = "Insert Into Inwards (SerialNumber,LetterNumber,DateOfEntry,Subject,From,LetterType,AssignedTo,BeltNumber,DateOfIssue) values(" + txtSerialNo.Text.Trim + "," + txtLetterNumber.Text.Trim + ",'" + lblDate.Text.Trim + "','" + txtSubject.Text.Trim + "','" + txtFrom.Text.Trim + "','" + cbType.Text.Trim + "','" + txtAssignedTo.Text.Trim + "','" + txtBeltNumber.Text.Trim + "','" + dtDOI.Text.Trim + "')"
cmd = New OleDb.OleDbCommand(str, con)
con.Open()
cmd.ExecuteNonQuery()
MsgBox("Inserted Successfully new Inward..")
'data()
'clearText()
Catch ex As Exception
Finally
con.Close()
End Try
推荐答案
INSERT INTO Table1 (DateField1)
VALUES(#2013/06/05#)
for text:
for text:
INSERT INTO Table1 (TextField1)
VALUES('any text')
的数值:
for numeric values:
INSERT INTO Table1 (NumericField1)
VALUES(1000)
有一个看这里:
[]
[]
这篇关于在vb.net和ms访问中的insert语句中获取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!