Results 1 to 5 of 5

Thread: [RESOLVED] ADO to ADO.Net coding(vb)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Location
    Colchester, England, U.K.
    Posts
    19

    Resolved [RESOLVED] ADO to ADO.Net coding(vb)

    In VB6 I did this
    Code:
           oFile rsUpd, "select * from blankvars"
            With rsUpd
                .MoveFirst
                Do While Not .EOF
                    ![oldcode] = gtID & ![oldcode]
                    .MoveNext
                Loop
                .Close
            End With
    SImply put I replace a column of data in a table updating as I go then close it.
    It's an Access .mdb & OFile opens the recordset.

    I would like to do the same but now using vb2010/ADO.Net. I must be missing something simple but any help appreciated.

  2. #2

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: ADO to ADO.Net coding(vb)

    This is the closest equivalent in VB.Net:-
    vbnet Code:
    1. '
    2.         Dim conn As New SqlConnection("Data Source=intel32;Integrated Security=True;Initial Catalog=DbSimple")
    3.         Dim cmd As New SqlCommand("Select * From Tbl1", conn)
    4.         conn.Open()
    5.  
    6.         Dim reader As SqlDataReader = cmd.ExecuteReader
    7.  
    8.  
    9.         Do While reader.Read
    10.             'Shows the value of the first column
    11.             MsgBox(reader.GetInt32(0))
    12.         Loop

    There are no RecordSets in VB.Net so we can't write back to the database that way. Much has changed. You should really study the link RhinoBull posted.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Location
    Colchester, England, U.K.
    Posts
    19

    Resolved Re: ADO to ADO.Net coding(vb)

    Thanks Guys,
    I'm ploughing through all the links and my heads all over the place. I'm finding vb.net much harder than I thought, things that used to be easy now seem so long winded. But I will persevere. Thanks for your help.

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [RESOLVED] ADO to ADO.Net coding(vb)

    Actually, after some time you would find that doing stuff in VB.Net is far easier and you can do so much more.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width