Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask 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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2009, 05:34 PM
Authorized User
 
Join Date: Jun 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Dataset Update Aaron Edwards ADO.NET 1 April 29th, 2005 04:26 AM
dataset to databse update nashnash ASP.NET 1.0 and 1.1 Professional 1 December 10th, 2004 01:05 PM
How to update the datasource from using dataset syedjavid ADO.NET 3 August 1st, 2004 02:58 PM
Dataset Update with Null Value [V] reyboy ADO.NET 2 June 1st, 2004 12:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.