Update a disconnected dataset
I am having issues updating data from a disconnected dataset. here is the code I am using {based upon a C# snipet]
PrivateSub UpdateDataSet(ByVal dsSource As DataSet, ByVal tblName AsString, ByRef sMsg AsString)
Dim conn AsNew OleDbConnection()
Try
' Code to get updated values from DataGrid
' Fetch the cached DataSet from the Session object
' Code to update the appropriate DataRow
Dim dv As DataView = dsSource.Tables(tblName).DefaultView
' Reconnect to the database and Open
conn.ConnectionString = m_dbConn.ConnectionString
conn.Open()
' Make a new OleDbDataAdapter
Dim da AsNew OleDbDataAdapter("SELECT * FROM " & tblName, conn)
' Make a new OleDbCommandBuilder
Dim cb AsNew OleDbCommandBuilder(da)
' Do the update and rebind the DataSet to the DataGrid
da.Update(dsSource, tblName)
Catch ex As Exception
sMsg = sWhoamI & "doUpdate|" & ex.Message
Finally
If conn.State = ConnectionState.Open Then
conn.Close()
EndIf
EndTry
EndSub
Thanks in advance.
|