|
-
May 21st, 2002, 01:02 PM
#1
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?
-
May 21st, 2002, 07:15 PM
#2
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
-
May 22nd, 2002, 08:13 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|