更新vb.net MS Access DB?

时间:2016-05-17 19:05:22

标签: asp.net vb.net ms-access updates

我一直在研究迷你库存软件,但我的编辑功能有问题。我到处看,看到多个例子没有答案似乎有效。我是vb.net编程的新手,所以请耐心等待xD

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles bAdd.Click

        If myConnection.State = ConnectionState.Closed Then myConnection.Open()
            Dim st As String = "UPDATE [ListProducts] SET [NameProduct] = '" & NamPro1.Text & "', [PricePro] = '" & PriPro1.Text & "'WHERE [ID] = '" & InventorioA.InventorioGrid.SelectedCells(0).Value & "'"

        Dim cmd As New OleDbCommand(st, myConnection)
            cmd.ExecuteNonQuery()
            myConnection.Close()
            InventorioA.fill()
            Me.Close()
    End Sub

如果它有助于我的数据库有多个表,并且特定的表被称为[ListProducts],其中包含3个列

[ID] [NameProduct] [PricePro]

我不知道解决方案,但如果有帮助我会收到此错误

  

[类型'System.ArgumentOutOfRangeException'的未处理异常   发生在mscorlib.ddl]

     

[补充资料:指数超出范围。必须是非负面的   并且小于集合的大小。]

0 个答案:

没有答案