0

我可以问一下吗,我在 INSERT INTO 语句中遇到语法错误。每当我按 ctrl+f5 时。我的代码有什么遗漏吗?

Protected Sub btnEnter_Click(sender As Object, e As System.EventArgs) Handles btnEnter.Click

    Dim CID As Integer = CInt(lblCno.Text)
    Dim tRentID As String = txtRentID.Text
    Dim pList As String = ProductList.Text
    Dim tDate As Date = lblDue.Text
    Dim amount As Integer = CInt(txtAmount.Text)
    Try
        Dim dbconn1, dbcomm1, dbex1, sql1
        dbconn1 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("~/App_Data/aspDatabase.mdb"))
        dbconn1.open()
        sql1 = "Insert into order VALUES ( " & "'" & tRentID & "'" & "," & "'" & tDate & "'" & "," & "'" & amount & "'" & "," & "'" & CID & "'" & "," & pList & ")"
        dbcomm1 = New OleDbCommand(sql1, dbconn1)
        dbex1 = dbcomm1.executenonquery
        dbconn1.Close()
    Catch ex As Exception
        lblOut.Text = ex.Message
    End Try
End Sub
End Class
4

1 回答 1

3

ORDER是保留关键字。将其括在方括号 [order] 中(或反引号,取决于您使用的数据库)。它是 Access 的方括号。

于 2013-07-28T03:34:37.897 回答