P
Paul M
hi there,
this is the source code i use to populate a dataset, bind it and perform the
update on any changes made to the datagrid.
Only problem is when i try the update, it does not save back to the
database....
any help is appreciated....thanks,
Paul.
Private ds As DataSet
sSQL = "SELECT * FROM [tblUser]"
..............
..............'BIND THE DATAGRID WITH TABLE DATA...works fine.
With dgTable
.CaptionText = SourceName
ds = CreateDataSet(sSQL, tableName)
.DataSource = ds.Tables(0)
End With
...............
...............
Function CreateDataSet(ByVal sql As String, ByVal tablename As String) As
DataSet
Dim da As OleDbDataAdapter
Try
cmd = New OleDbCommand
cmd.CommandText = sql
cmd.Connection = conn
da = New OleDbDataAdapter(cmd)
ds = New DataSet(tablename)
da.Fill(ds)
CreateDataSet = ds
Catch ex As Exception
CreateDataSet = Nothing
Finally
da.Dispose()
da = Nothing
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
ds.GetChanges()
ds.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message, "Save Changes", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End Try
End Sub
this is the source code i use to populate a dataset, bind it and perform the
update on any changes made to the datagrid.
Only problem is when i try the update, it does not save back to the
database....
any help is appreciated....thanks,
Paul.
Private ds As DataSet
sSQL = "SELECT * FROM [tblUser]"
..............
..............'BIND THE DATAGRID WITH TABLE DATA...works fine.
With dgTable
.CaptionText = SourceName
ds = CreateDataSet(sSQL, tableName)
.DataSource = ds.Tables(0)
End With
...............
...............
Function CreateDataSet(ByVal sql As String, ByVal tablename As String) As
DataSet
Dim da As OleDbDataAdapter
Try
cmd = New OleDbCommand
cmd.CommandText = sql
cmd.Connection = conn
da = New OleDbDataAdapter(cmd)
ds = New DataSet(tablename)
da.Fill(ds)
CreateDataSet = ds
Catch ex As Exception
CreateDataSet = Nothing
Finally
da.Dispose()
da = Nothing
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
ds.GetChanges()
ds.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message, "Save Changes", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End Try
End Sub