在vb中插入数据库不起作用

时间:2016-02-06 22:45:05

标签: vb.net

我有这段代码在INSERT INTO语句中给出语法错误。有什么帮助吗?

Dim lo As String = "INSERT INTO tblTrans(Book ID,Student ID,Date Borrowed,Returned )VALUES( @parm1, @parm2 , @parm3 , @parm4 )"
Dim cmd55 As New OleDb.OleDbCommand(lo, connectors2)
cmd55.Parameters.Add("@parm1", OleDb.OleDbType.WChar, 10).Value = str5
cmd55.Parameters.Add("@parm2", OleDb.OleDbType.WChar, 5).Value = std
cmd55.Parameters.Add("@parm3", OleDb.OleDbType.Date).Value = str11
cmd55.Parameters.Add("@parm4", OleDb.OleDbType.WChar, 255).Value = str12
cmd55.CommandType = CommandType.Text
cmd55.ExecuteNonQuery()

1 个答案:

答案 0 :(得分:0)

您的陈述应在更改列名后

Dim lo As String = "INSERT INTO tblTrans(Book_ID,Student_ID,Date_Borrowed,Returned ) VALUES ( @parm1, @parm2 , @parm3 , @parm4 )"

同时将str11转换为插入前的日期。