Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 18th, 2003, 04:31 PM
Registered User
Join Date: Jul 2003
Location: Morristown, TN, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ozymandias Send a message via Yahoo to Ozymandias
Default Dataset Question

Here's my code...

    Private oConn As New OleDb.OleDbConnection()
    Private oCommand As New OleDb.OleDbCommand()
    Private oDataAdapter As New OleDb.OleDbDataAdapter()
    Private oDataSet As New DataSet()

    Public Event Err()

    Public Sub Init()

        Dim Row As DataRow

        oConn.ConnectionString = _
            "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
            Application.StartupPath & _
            "\WinMUX.mdb;Persist Security Info=False"

        oCommand.CommandText = "SELECT Name FROM Objects"
        oCommand.Connection = oConn
        oCommand.CommandTimeout = 30
        oDataAdapter.SelectCommand = oCommand
        oDataAdapter.Fill(oDataSet, "Objects")

        For Each Row In oDataSet.Tables("Objects").Rows
            If Row("Name") = "Brimstone" Then
                Row("Name") = "NotBrimstone"
            End If
        oDataAdapter.Update(oDataSet, "Objects")

    End Sub

I know it isn't the prettiest code but I'm just trying to figure this Data Access stuff out in .NET. How do I update the data in the database with what has been changed in the Dataset? I'm completely lost. With ADO you used to just call the adoRecordset.Update method. What do you do now?

Andrew Cooper
Reply With Quote
  #2 (permalink)  
Old November 19th, 2003, 12:00 PM
Friend of Wrox
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts

Each row in the data set has a version, which tracks the type of change made to the data set, so if it was added, updated, deleted, etc, that's how it tracks the changes. In looking at your code, it looks like you got the right idea, you call the DataAdapter's update statement to make the change to the dataset, and the parameters you passed in are right.

Are you having any specific problems?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset question MaxGay2 VB.NET 2002/2003 Basics 1 November 16th, 2006 10:33 AM
Dataset Designer Question chrislepingwell ADO.NET 0 August 31st, 2006 06:27 AM
Dataset Question katsarosj ASP.NET 1.0 and 1.1 Basics 9 December 1st, 2005 07:05 AM

All times are GMT -4. The time now is 12:19 PM.

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