0

I want to update data using DataGridView in Visual Studio2008 with the following code. But it is not working. Plz help me.

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
cmd = New Odbc.OdbcCommand("UPDATE Table1 SET Name")
Me.Table1TableAdapter.Update(DataSet1.Table1)
MsgBox("Updated")
End Sub

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by c0deFr3aK
0

I want to update data using DataGridView in Visual Studio2008 with the following code. But it is not working. Plz help me.

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
cmd = New Odbc.OdbcCommand("UPDATE Table1 SET Name")
Me.Table1TableAdapter.Update(DataSet1.Table1)
MsgBox("Updated")
End Sub

i'll give you an example how to Update in VB.NET

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
       Dim conn As New Odbc.OdbcConnection("Your Strings Here")
       conn.Open()
       Dim da As New Odbc.OdbcDataAdapter("SELECT * FROM yourTable WHERE Field1 = MyText", conn)
       Dim ds As New DataSet
       Dim cb As New Odbc.OdbcCommandBuilder(da)
       da.Fill(ds)
    
          If ds.Tables(0).Rows.Count = 1 Then
              da.Update(ds)
          MsgBox("Updated")
           End If
     
    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.