Vb.net 错误:";INSERT INTO语句中的语法错误;

Vb.net 错误:";INSERT INTO语句中的语法错误;,vb.net,Vb.net,我使用的是vb.NET2010,我的提供商是OLEDB。我正在使用vb.net制作一个数据库程序,该程序通过我创建的导航按钮遍历数据库,但是,在按下提交或更新按钮后,我出现以下错误。错误是{INSERT INTO语句中的语法错误。}它发生在{dataadapter.Update(dataset,“GRE Library”)}的两个按钮中的两个位置 据我所知,其他一切都很好。我确实有其他形式,但它们并不真正重要或相互关联 这是我的密码: Public Class EditLibraryForm

我使用的是vb.NET2010,我的提供商是OLEDB。我正在使用vb.net制作一个数据库程序,该程序通过我创建的导航按钮遍历数据库,但是,在按下提交或更新按钮后,我出现以下错误。错误是{INSERT INTO语句中的语法错误。}它发生在{dataadapter.Update(dataset,“GRE Library”)}的两个按钮中的两个位置
据我所知,其他一切都很好。我确实有其他形式,但它们并不真正重要或相互关联

这是我的密码:

Public Class EditLibraryForm

Dim MaxRows As Integer
Dim inc As Integer
Dim connection As New OleDb.OleDbConnection
Dim databaseProvider As String
Dim databaseSource As String

Dim dataset As New DataSet
Dim dataadapter As OleDb.OleDbDataAdapter
Dim sql As String

Private Sub EditLibraryForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    databaseProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
    databaseSource = "Data Source = H:\Game Revolutionaries Entertainment TEST2\Game Revolutionaries Entertainment\Resource\GRE Library.accdb"
    connection.ConnectionString = databaseProvider & databaseSource

    connection.Open()
    sql = "SELECT * FROM [GRE Library Logistics]"
    dataadapter = New OleDb.OleDbDataAdapter(sql, connection)
    dataadapter.Fill(dataset, "GRE Library")

    connection.Close()

    MaxRows = dataset.Tables("GRE Library").Rows.Count
    inc = -1

End Sub

Private Sub NavigateRecords()

    txtname.Text = dataset.Tables("GRE Library").Rows(inc).Item(0).ToString
    txtrating.Text = dataset.Tables("GRE Library").Rows(inc).Item(2).ToString
    txtgenre.Text = dataset.Tables("GRE Library").Rows(inc).Item(3).ToString
    txtplatform.Text = dataset.Tables("GRE Library").Rows(inc).Item(4).ToString
    txtrd.Text = dataset.Tables("GRE Library").Rows(inc).Item(5).ToString
    txtdc.Text = dataset.Tables("GRE Library").Rows(inc).Item(6).ToString
    txtinfo.Text = dataset.Tables("GRE Library").Rows(inc).Item(7).ToString
    txtpn.Text = dataset.Tables("GRE Library").Rows(inc).Item(8).ToString
    txtsupport.Text = dataset.Tables("GRE Library").Rows(inc).Item(9).ToString
    txtnews.Text = dataset.Tables("GRE Library").Rows(inc).Item(10).ToString


End Sub
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click

    If inc <> MaxRows - 1 Then
        inc = inc + 1
        NavigateRecords()
    Else
        MsgBox("No More items in Library")
    End If

End Sub

Private Sub btnprevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprevious.Click

    If inc > 0 Then
        inc = inc - 1
        NavigateRecords()
    Else
        MsgBox("This is First item")
    End If

End Sub

Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click

    If inc <> MaxRows - 1 Then
        inc = MaxRows - 1
        NavigateRecords()
    Else
        MsgBox("Already on last item")
    End If

End Sub

Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click

    If inc <> 0 Then
        inc = 0
        NavigateRecords()
    Else
        MsgBox("Already on first item")
    End If

End Sub

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click

    Dim cb As New OleDb.OleDbCommandBuilder(dataadapter)

    txtname.Text = dataset.Tables("GRE Library").Rows(inc).Item(0).ToString
    txtrating.Text = dataset.Tables("GRE Library").Rows(inc).Item(2).ToString
    txtgenre.Text = dataset.Tables("GRE Library").Rows(inc).Item(3).ToString
    txtplatform.Text = dataset.Tables("GRE Library").Rows(inc).Item(4).ToString
    txtrd.Text = dataset.Tables("GRE Library").Rows(inc).Item(5).ToString
    txtdc.Text = dataset.Tables("GRE Library").Rows(inc).Item(6).ToString
    txtinfo.Text = dataset.Tables("GRE Library").Rows(inc).Item(7).ToString
    txtpn.Text = dataset.Tables("GRE Library").Rows(inc).Item(8).ToString
    txtsupport.Text = dataset.Tables("GRE Library").Rows(inc).Item(9).ToString
    txtnews.Text = dataset.Tables("GRE Library").Rows(inc).Item(10).ToString



    dataset.Tables("GRE Library").Rows(inc).Item(0) = txtname.Text
    dataset.Tables("GRE Library").Rows(inc).Item(2) = txtrating.Text
    dataset.Tables("GRE Library").Rows(inc).Item(3) = txtgenre.Text
    dataset.Tables("GRE Library").Rows(inc).Item(4) = txtplatform.Text
    dataset.Tables("GRE Library").Rows(inc).Item(5) = txtrd.Text
    dataset.Tables("GRE Library").Rows(inc).Item(6) = txtdc.Text
    dataset.Tables("GRE Library").Rows(inc).Item(7) = txtinfo.Text
    dataset.Tables("GRE Library").Rows(inc).Item(8) = txtpn.Text
    dataset.Tables("GRE Library").Rows(inc).Item(9) = txtsupport.Text
    dataset.Tables("GRE Library").Rows(inc).Item(10) = txtnews.Text


    dataadapter.Update(dataset, "GRE Library")
    MsgBox("Library updated")

End Sub

Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click

    btncommit.Enabled = True
    btnaddnew.Enabled = False
    btnupdate.Enabled = False
    btndelete.Enabled = False

    txtname.Clear()
    txtrating.Clear()
    txtgenre.Clear()
    txtplatform.Clear()
    txtrd.Clear()
    txtdc.Clear()
    txtinfo.Clear()
    txtpn.Clear()
    txtsupport.Clear()
    txtnews.Clear()

End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click

    btncommit.Enabled = False
    btnaddnew.Enabled = True
    btnupdate.Enabled = True
    btndelete.Enabled = True

    inc = 0
    NavigateRecords()

End Sub

Private Sub btncommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncommit.Click

    If inc <> -1 Then

        Dim cb As New OleDb.OleDbCommandBuilder(dataadapter)
        Dim datasetNewRow As DataRow

        datasetNewRow = dataset.Tables("GRE Library").NewRow()

        datasetNewRow.Item("Name") = txtname.Text
        datasetNewRow.Item("PersonelRating") = txtrating.Text
        datasetNewRow.Item("Genre") = txtgenre.Text
        datasetNewRow.Item("Platform") = txtplatform.Text
        datasetNewRow.Item("ReleaseDate") = txtrd.Text
        datasetNewRow.Item("DevelopingCompany") = txtdc.Text
        datasetNewRow.Item("GameInformation") = txtinfo.Text
        datasetNewRow.Item("PersonalNotes") = txtpn.Text
        datasetNewRow.Item("Support") = txtsupport.Text
        datasetNewRow.Item("News") = txtnews.Text


        dataset.Tables("GRE Library").Rows.Add(datasetNewRow)

        dataadapter.Update(dataset, "GRE Library")

        MsgBox("New item has been added to the library")

        btncommit.Enabled = False
        btnaddnew.Enabled = True
        btnupdate.Enabled = True
        btndelete.Enabled = True

    End If

End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click


    Dim cb As New OleDb.OleDbCommandBuilder(dataadapter)
    dataset.Tables("GRE Library").Rows(inc).Delete()
    MaxRows = MaxRows - 1

    inc = 0
    NavigateRecords()
    dataadapter.Update(dataset, "GRE Library")

End Sub
公共类编辑库表单
将MaxRows设置为整数
作为整数的Dim公司
Dim连接作为新的OleDb.OleDb连接
Dim数据库提供程序作为字符串
将数据库源设置为字符串
将数据集设置为新数据集
Dim数据适配器作为OleDb.OleDbDataAdapter
将sql设置为字符串
Private Sub EditLibrary Form_Load(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理MyBase.Load
databaseProvider=“Provider=Microsoft.ACE.OLEDB.12.0;”
databaseSource=“Data Source=H:\Game Revolutionaries Entertainment TEST2\Game Revolutionaries Entertainment\Resource\GRE Library.accdb”
connection.ConnectionString=数据库提供程序和数据库源
connection.Open()
sql=“从[GRE图书馆物流]中选择*”
dataadapter=新的OleDb.OleDbDataAdapter(sql,连接)
dataadapter.Fill(数据集,“GRE库”)
连接。关闭()
MaxRows=dataset.Tables(“GRE库”).Rows.Count
inc=-1
端接头
专用子导航记录()
txtname.Text=dataset.Tables(“GRE库”).Rows(inc).Item(0).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(2).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(3).ToString
txtmplatform.Text=dataset.Tables(“GRE库”).Rows(inc).Item(4).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(5).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(6).ToString
txtinfo.Text=dataset.Tables(“GRE库”).Rows(inc).Item(7).ToString
txtpn.Text=dataset.Tables(“GRE库”).Rows(inc).Item(8).ToString
txtsupport.Text=dataset.Tables(“GRE库”).Rows(inc).Item(9).ToString
txtnews.Text=dataset.Tables(“GRE库”).Rows(inc).Item(10).ToString
端接头
私有子btnnext\u单击(ByVal发送方作为System.Object,ByVal e作为System.EventArgs)处理btnnext。单击
如果inc MaxRows-1,则
inc=inc+1
导航记录()
其他的
MsgBox(“库中不再有项目”)
如果结束
端接头
Private Sub btnprevious_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btnprevious。单击
如果inc>0,则
inc=inc-1
导航记录()
其他的
MsgBox(“这是第一项”)
如果结束
端接头
Private Sub btnlast_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btnlast。Click
如果inc MaxRows-1,则
inc=最大行数-1
导航记录()
其他的
MsgBox(“已在最后一项中”)
如果结束
端接头
私有子btnfirst_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btnfirst。单击
如果是0那么
inc=0
导航记录()
其他的
MsgBox(“已在第一项中”)
如果结束
端接头
私有子btnupdate_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btnupdate。单击
作为新OleDb.OleDbCommandBuilder(数据适配器)的尺寸cb
txtname.Text=dataset.Tables(“GRE库”).Rows(inc).Item(0).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(2).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(3).ToString
txtmplatform.Text=dataset.Tables(“GRE库”).Rows(inc).Item(4).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(5).ToString
Text=dataset.Tables(“GRE库”).Rows(inc).Item(6).ToString
txtinfo.Text=dataset.Tables(“GRE库”).Rows(inc).Item(7).ToString
txtpn.Text=dataset.Tables(“GRE库”).Rows(inc).Item(8).ToString
txtsupport.Text=dataset.Tables(“GRE库”).Rows(inc).Item(9).ToString
txtnews.Text=dataset.Tables(“GRE库”).Rows(inc).Item(10).ToString
dataset.Tables(“GRE库”).Rows(inc.Item(0)=txtname.Text
dataset.Tables(“GRE库”).Rows(inc.Item(2)=txtrating.Text
dataset.Tables(“GRE库”).Rows(inc.Item(3)=txtgree.Text
dataset.Tables(“GRE库”).Rows(inc.Item(4)=txtplatform.Text
dataset.Tables(“GRE库”).Rows(inc.Item(5)=txtrd.Text
dataset.Tables(“GRE库”).Rows(inc.Item(6)=txtdc.Text
dataset.Tables(“GRE库”).Rows(inc.Item(7)=txtinfo.Text
dataset.Tables(“GRE库”).Rows(inc.Item(8)=txtpn.Text
dataset.Tables(“GRE库”).Rows(inc.Item(9)=txtsupport.Text
dataset.Tables(“GRE库”).Rows(inc.Item(10)=txtnews.Text
dataadapter.Update(数据集,“GRE库”)
MsgBox(“库更新”)
端接头
私有子btnaddnew_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理btnaddnew。单击
btncommit.Enabled=True
btnaddnew.Enabled=False
btnupdate.Enabled=False
btndelete.Enabled=False
txtname.Clear()
txtrating.Clear()
txtgree.Clear()
txtmplatform.Clear()
txtrd.Clear()
txtdc.Clear()
txtinfo.Clear()
txtpn.Clear()
txtsupport.Clear()
txtnews.Clear()
端接头
Private Sub btnclear\u Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btnclear。Click
btncommit.Enabled=False
btnaddnew.Enabled=True
btnupdate.Enabled=True
btndelete.Enabled=True
inc=0
导航记录()
端接头
私有子btncommit_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理btncommit。单击
如果inc-1那么
作为新OleDb.OleDbCommandBuilder(数据适配器)的尺寸cb
Dim datasetNewRow作为DataRow
datasetNewRow=dataset.Ta