G
Guest
Hi, I'm using vb.net.
My dataset is not updating my database after the user modifies the datagrid.
I populate my data with the load sub below.
In the Save Sub (below), I have generated my DataSet 'dataSet11' from my
DataAdaptor 'SqlDataAdapter1' and the DataConnection 'SqlConnection1' and
they all seem to be connected correctly. But my data does not update.
the dataAdaptor is configured for Insert/Update/delete and the datagrid
datasource is DataSet11.TableName. Any ideas?
Private Sub Thresholds_Load(ByVal sender As.....
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text & ";password="
& Password.Text & ";database=" & Database.Text & ";server=" & Server.Text)
cn.Open()
cmdSelect.Connection = cn
Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("Select
* from MISRE_Threshold", cn)
Dim dsThreshold As DataSet = New DataSet
' fill dataset
da.Fill(dsThreshold, "MISRE_Threshold")
'Attach DataSet to DataGrid
dgThreshold.DataSource = dsThreshold.DefaultViewManager
Catch ex As Exception
MessageBox.Show("Error: Could not establish database connection")
End Try
Private Sub btnSave_Click(ByVal sender.....
SqlDataAdapter1.Update(DataSet11)
EndSub
My dataset is not updating my database after the user modifies the datagrid.
I populate my data with the load sub below.
In the Save Sub (below), I have generated my DataSet 'dataSet11' from my
DataAdaptor 'SqlDataAdapter1' and the DataConnection 'SqlConnection1' and
they all seem to be connected correctly. But my data does not update.
the dataAdaptor is configured for Insert/Update/delete and the datagrid
datasource is DataSet11.TableName. Any ideas?
Private Sub Thresholds_Load(ByVal sender As.....
Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text & ";password="
& Password.Text & ";database=" & Database.Text & ";server=" & Server.Text)
cn.Open()
cmdSelect.Connection = cn
Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("Select
* from MISRE_Threshold", cn)
Dim dsThreshold As DataSet = New DataSet
' fill dataset
da.Fill(dsThreshold, "MISRE_Threshold")
'Attach DataSet to DataGrid
dgThreshold.DataSource = dsThreshold.DefaultViewManager
Catch ex As Exception
MessageBox.Show("Error: Could not establish database connection")
End Try
Private Sub btnSave_Click(ByVal sender.....
SqlDataAdapter1.Update(DataSet11)
EndSub