Datagridview Update with SQLCommandBuilder Problem
Posted on 2012-03-18
I have a WinForms app and have a situation where I fill a Datagridview with info and then the connection to the Database is closed. It could some time later that the person needs to edit a cell in the Datagridview.
This code works with the connection already open. But, if it is not open, what do I need to add to this code to get the Update to work? The connection to the sqlserver needs to be re-established. Or, does the connection need to be Open at all times?
Dim cb As New Data.SqlClient.SqlCommandBuilder(DataAdapter)
Catch ex As Exception
I am trying to follow the best practice of closing the connection when not needed.