VB How-ToAsk your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
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