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 'SqlDataAdapter 1' 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.Table Name. Any ideas?
Private Sub Thresholds_Load (ByVal sender As.....
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text & ";password= "
& Password.Text & ";database= " & Database.Text & ";server=" & Server.Text)
cn.Open()
cmdSelect.Conne ction = cn
Dim da As SqlClient.SqlDa taAdapter = New SqlClient.SqlDa taAdapter("Sele ct
* from MISRE_Threshold ", cn)
Dim dsThreshold As DataSet = New DataSet
' fill dataset
da.Fill(dsThres hold, "MISRE_Threshol d")
'Attach DataSet to DataGrid
dgThreshold.Dat aSource = dsThreshold.Def aultViewManager
Catch ex As Exception
MessageBox.Show ("Error: Could not establish database connection")
End Try
Private Sub btnSave_Click(B yVal sender.....
SqlDataAdapter1 .Update(DataSet 11)
EndSub
I populate my data with the load sub below.
In the Save Sub (below), I have generated my DataSet 'dataSet11' from my
DataAdaptor 'SqlDataAdapter 1' 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.Table Name. Any ideas?
Private Sub Thresholds_Load (ByVal sender As.....
Try
cn = New SqlClient.SqlCo nnection("user id=" & UserName.Text & ";password= "
& Password.Text & ";database= " & Database.Text & ";server=" & Server.Text)
cn.Open()
cmdSelect.Conne ction = cn
Dim da As SqlClient.SqlDa taAdapter = New SqlClient.SqlDa taAdapter("Sele ct
* from MISRE_Threshold ", cn)
Dim dsThreshold As DataSet = New DataSet
' fill dataset
da.Fill(dsThres hold, "MISRE_Threshol d")
'Attach DataSet to DataGrid
dgThreshold.Dat aSource = dsThreshold.Def aultViewManager
Catch ex As Exception
MessageBox.Show ("Error: Could not establish database connection")
End Try
Private Sub btnSave_Click(B yVal sender.....
SqlDataAdapter1 .Update(DataSet 11)
EndSub
Comment