nbrege

I know there have been many posts here about this subject & I have read them all but I still can't figure out how to do it. I have a DGV on a form that I am populating with data from a table in an Informix database. The user can specify the table name in a textbox & the program executes a "Select * from ..." query on the table & fills the DGV with all the data. Depending on the table, there could be any number of rows & columns. That part is working fine. Now I want to be able to edit the value in any cell(s) in the DGV & press a "Save" button & have the changes written to the database. That is the part I dont know how to do. This is the code I am using to load the table data into the DGV:

Code Snippet
Private Sub LoadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadButton.Click

Dim QueryString As String = "select * from " & Me.TextBox1.Text

Dim Connect As New Odbc.OdbcConnection(MyConnectionString)
Dim myAdapter As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter(QueryString, Connect)
Dim myDataTable As DataTable = New DataTable

Me.DataGridView1.DataSource = DBNull.Value
myDataTable.Clear()
Dim count As Integer = myAdapter.Fill(myDataTable)

Me.DataGridView1.DataSource = myDataTable

End Sub

Could someone please help with the code I need to use in the "Save" button click event that will update the Informix table with any changes that were made in the DGV I have been struggling with this for several weeks now & I just can't get it to work. Thanks for any help...



Re: .NET Framework Data Access and Storage Using DataGridView to update database table

Feng Chen - MSFT

Hi nbrege,
I am moving this thread from Visual Basic Express Edition forum to the .NET Framework Data Access and Storage forum, since the issue is related to ADO.net. There are more ADO.net experts in the .NET Framework Data Access and Storage forum.
Thanks for your understanding!





Re: .NET Framework Data Access and Storage Using DataGridView to update database table

nbrege

Can anyone help me with this