1 Replies - 711 Views - Last Post: 30 June 2013 - 12:34 PM Rate Topic: -----

#1 pharaon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 18-October 07

Update requires a valid UpdateCommand when passed DataRow collection

Posted 30 June 2013 - 12:31 PM

Private stable As String
    Private con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & Application.StartupPath & "\confess.accdb")
    Dim sqlstr As String
    Private adapter As OleDb.OleDbDataAdapter
    Private table As New DataTable

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Select Case True
            Case RadioButton1.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & TextBox1.Text & "%'"
                adapter = New OleDb.OleDbDataAdapter(sqlstr, con)
                adapter.Fill(table)

            Case RadioButton2.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & TextBox1.Text & "%'"
                adapter.Fill(table)

            Case RadioButton3.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & ComboBox2.Text & "%'"
                adapter.Fill(table)

            Case RadioButton4.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & ComboBox2.Text & "%'"
                adapter.Fill(table)

            Case RadioButton5.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & TextBox1.Text & "%'"
                adapter.Fill(table)

            Case RadioButton6.Checked
                sqlstr = " select *  from [names] where " & stable & " like '%" & ComboBox2.Text & "%'"
                adapter.Fill(table)

        End Select
        DataGridView1.DataSource = table
    End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        adapter.Update(table)
End Sub



I get this error when I try to update the database with the modified cells in the DGV

Update requires a valid UpdateCommand when passed DataRow collection with modified rows

Is This A Good Question/Topic? 0
  • +

Replies To: Update requires a valid UpdateCommand when passed DataRow collection

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Update requires a valid UpdateCommand when passed DataRow collection

Posted 30 June 2013 - 12:34 PM

Probably have better luck in VB.NET.

Moved there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1