Hey, I have never used a datagrid/dataset/adaptor/table method for updating
data, I have always used direct updates to the database so ADO is quite new
to me.
I have a datagrid and I change a value in one of the fields.
I hit save and the following code runs...
Dim da As SqlClient.SqlDa taAdapter = New SqlClient.SqlDa taAdapter("Sele ct *
from MISRE_Threshold ", cn)
da.Update(dsThr eshold, "MISRE_Threshol d")
my code to populate the datagrid is as below, what am i missing to actually
update the data in the database......
Private Sub Thresholds_Load (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
UserName.Text = dbProps.MyUserN ame
Password.Text = dbProps.MyPassw ord
Database.Text = dbProps.MyDatab ase
Server.Text = dbProps.MyServe r
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
Dim dt As New DataTable
dt.CaseSensitiv e = False
dt = dsThreshold.Tab les("MISRE_Thre shold")
Catch ex As Exception
MessageBox.Show ("Error: Could not establish database connection")
End Try
End Sub
data, I have always used direct updates to the database so ADO is quite new
to me.
I have a datagrid and I change a value in one of the fields.
I hit save and the following code runs...
Dim da As SqlClient.SqlDa taAdapter = New SqlClient.SqlDa taAdapter("Sele ct *
from MISRE_Threshold ", cn)
da.Update(dsThr eshold, "MISRE_Threshol d")
my code to populate the datagrid is as below, what am i missing to actually
update the data in the database......
Private Sub Thresholds_Load (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
UserName.Text = dbProps.MyUserN ame
Password.Text = dbProps.MyPassw ord
Database.Text = dbProps.MyDatab ase
Server.Text = dbProps.MyServe r
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
Dim dt As New DataTable
dt.CaseSensitiv e = False
dt = dsThreshold.Tab les("MISRE_Thre shold")
Catch ex As Exception
MessageBox.Show ("Error: Could not establish database connection")
End Try
End Sub
Comment