Wrox Programmer Forums
|
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 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 November 18th, 2003, 04:31 PM
Registered User
 
Join Date: Jul 2003
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
            MsgBox(Row("Name"))
            If Row("Name") = "Brimstone" Then
                Row("Name") = "NotBrimstone"
            End If
        Next
        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
[email protected]
 
Old November 19th, 2003, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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?

Brian





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





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