Ms access 错误数据库:INSERT INTO语句中的语法错误

Ms access 错误数据库:INSERT INTO语句中的语法错误,ms-access,vb.net-2010,Ms Access,Vb.net 2010,我的图书馆系统有问题。我得到一个错误,声明“错误数据库:INSERT INTO语句中的语法错误”。我正在使用Access访问数据库。 这是我的密码: Public Class Form7 Private Sub Form7_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Me.Text = "Regis

我的图书馆系统有问题。我得到一个错误,声明“错误数据库:INSERT INTO语句中的语法错误”。我正在使用Access访问数据库。 这是我的密码:

Public Class Form7
    Private Sub Form7_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.Text = "Registration"
        sqlCon.Close()
        sqlCon.Close()
        clear()
    End Sub

    Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Split(Me.Text, " - ")(1) = "Edit" Then
            sqlSTR = "Select * From BookRegister WHERE id = " & globalID
            ExecuteSQLQuery(sqlSTR)
            If sqlDr.Read Then
                TextBox1.Text = sqlDr(1)
                TextBox2.Text = sqlDr(2)
                TextBox3.Text = sqlDr(3)
                TextBox4.Text = sqlDr(4)
                TextBox5.Text = sqlDr(5)
                TextBox6.Text = sqlDr(6)
                TextBox7.Text = sqlDr(7)
                TextBox7.Text = sqlDr(8)

            End If

        End If
    End Sub

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            MsgBox("Please fill up all the information", MsgBoxStyle.Information)
        ElseIf TextBox2.Text = "" Then
            MsgBox("Please fill up all the information", MsgBoxStyle.Information)
        ElseIf TextBox3.Text = "" Then
            MsgBox("Please fill up your information", MsgBoxStyle.Information)
        ElseIf TextBox4.Text = "" Then
            MsgBox("Please fill up your information", MsgBoxStyle.Information)
        ElseIf TextBox5.Text = "" Then
            MsgBox("Please fill up your information", MsgBoxStyle.Information)
        ElseIf TextBox6.Text = "" Then
            MsgBox("Please fill up your information", MsgBoxStyle.Information)
        ElseIf TextBox7.Text = "" Then
            MsgBox("Please fill up all the information", MsgBoxStyle.Information)
        ElseIf TextBox8.Text = "" Then
            MsgBox("Please fill up all the information", MsgBoxStyle.Information)
        ElseIf Split(Me.Text, " - ")(1) = "Add" Then
            sqlSTR = "INSERT INTO BookRegister(ISBN, Title, Author, Volume, Pages, Publisher, Section, Year_Published) " & _
                              "VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "'" & _
                              ",'" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & ")"""

            ExecuteSQLQuery(sqlSTR)
            MsgBox("New record has been saved.", MsgBoxStyle.Information)

            clear()
        Else
            sqlSTR = "UPDATE BookRegister SET ISBN ='" & TextBox1.Text & "', " & _
                     "title='" & TextBox2.Text & "', " & _
                     "author='" & TextBox3.Text & "', " & _
                     "volume='" & TextBox4.Text & "', " & _
                     "pages='" & TextBox5.Text & "', " & _
                     "publisher='" & TextBox6.Text & "', " & _
                     "section='" & TextBox7.Text & "', " & _
                     "year_published='" & Format("yyyy", TextBox8.Text) & "', " & _
                     " WHERE id =" & globalID
            ExecuteSQLQuery(sqlSTR)
            MsgBox("Record has been updated !!", MsgBoxStyle.Information)
            clear()
            globalID = 0
            edit = False
            Me.Close()
        End If
        FillListView(Form6.ListView1, ExecuteSQLQuery("select * from bookregister"))
    End Sub


    Private Sub clear()
        Textbox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""


    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub
End Class  

看起来您在INSERT语句末尾缺少最后一个单引号,然后在右括号后追加一个无关的双引号,即

& "','" & TextBox8.Text & ")"""
应该是

& "','" & TextBox8.Text & "')"