CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Location
    Minneapolis, MN, USA
    Posts
    150

    Moving through Recordsets in VB.NET

    Does anyone know how to move through a recordset in VB.NET? AND get a record count? I'm trying to get all the records in a table and throw them into a 2-dimensional array. Any ideas?

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878
    A disconnected Recordset is retrieved in much the same way as a forward-only Recordset. So is a Recordset
    that uses a dynamic cursor. This is not the case with a DataSet, which requires, at least in the following
    example, a DataAdapter to handle the data population. Thus, while ADO had common methods for creating
    different kinds of Recordsets, ADO.NET has specific methods for creating different forms of data repositories.

    ' This is a Visual Basic 6 Dynamic Cursor Recordset Example
    Function VB6DynamicRSExample(connStr As String, _
    statement As String) As Recordset
    Dim rs As New ADODB.Recordset
    rs.Open statement, connStr, adOpenDynamic

    Set rs = conn.Execute(statement)
    Set VB6DynamicRSExample = rs
    Set rs = Nothing
    End Function

    ' This is a Visual Basic .NET DataSet Example
    Function VBNETDataSetExample(ByVal connStr As String, _
    ByVal statement As String) As DataSet
    Dim adapter As New OleDbDataAdapter(statement, connStr)
    Dim ds As New DataSet()

    adapter.Fill(ds)
    Return ds
    End Function

    '---navigate through table-----
    Dim row As DataRow
    For Each row In ds.Tables(0).Rows
    ' Do stuff
    Next

    Dim i As Integer
    For i = 0 To ds.Tables(0).Rows.Count - 1
    row = ds.Tables(0).Rows(i)
    ' Do other stuff
    Next
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Location
    Minneapolis, MN, USA
    Posts
    150
    tHANKS ONCE AGAIN.........

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

Featured