Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 April 11th, 2005, 11:28 PM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default NextRecordset method in ADO.NET?

Hi Everyone!

Is there a method in ADO.NET equivalent to the NextRecordset method of the classic ADO? How does it work in ADO.NET?

Thanks a lot!

Clay

 
Old April 12th, 2005, 01:32 AM
Registered User
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to lsxx
Default

try DataReader Object£¡
I think this can help you

Candle
 
Old April 13th, 2005, 08:22 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

There is no RecordSet object in ADO.NET and therefore no NextRecordset method.

Instead, you would normally use a DataSet which can hold multiple tables. I know that in the ADODB world you can tack two queries together with ; and the result will be a single ADODB.RecordSet object where you use NextRecordSet to advance. I don't know if there is an equivalent in ADO.NET.

-Peter
 
Old April 14th, 2005, 03:38 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Record Position and Navigation in Datasets (url follows)

Because a dataset is a fully disconnected container for data, datasets (unlike ADO recordsets) do not need or support the concept of a current record. Instead, all records in the dataset are available.

Because there is no current record, there is no specific property that points to a current record and there are no methods or properties for moving from one record to another. (In contrast, ADO recordsets support an absolute record position and methods to move from one record to the next.) You can access individual tables in the dataset as objects; each table exposes a collection of rows. You can treat this like any collection, accessing rows via the collection's index or using collection-specific statements in your programming language.

see:
http://msdn.microsoft.com/library/en...asp?frame=true

'I made my own code:
Public Class DataSetScroll
    Private m_dataSet As DataSet = Nothing
    Private m_rowCounter As Int32 = -1
    Private m_tableName As String = ""
    Public ReadOnly Property DataSet() As DataSet
        Get
            Return m_dataSet
        End Get
    End Property
    Public ReadOnly Property RowNumber() As Int32
        Get
            Return m_rowCounter
        End Get
    End Property

    Public Sub New(ByRef ds As DataSet, ByVal tableName As String)
        m_dataSet = ds
        m_tableName = tableName
    End Sub
    Public Function MoveNext() As Boolean
        If m_dataSet.Tables(m_tableName).Rows.Count - 1 <= m_rowCounter Then Return False
        '
        m_rowCounter += 1
        Return True
    End Function
    Public Function CurrentRow() As DataRow
        'row-pointer-counter initialized?
        If m_rowCounter = -1 Then
            If m_dataSet.Tables(m_tableName).Rows.Count > 0 Then
                m_rowCounter = 0
            Else
                Throw New Exception("Table """ & m_tableName & """ has no rows, it is empty!")
            End If
        End If
        '
        Return m_dataSet.Tables(m_tableName).Rows(m_rowCounter)
    End Function
    Public Function IsEmpty() As Boolean
        If m_dataSet.Tables(m_tableName).Rows.Count < 1 Then
            Return True '=is empty
        Else
            Return False '=is NOT empty
        End If
    End Function
End Class


'and use:
Dim dss As DataSetScroll = a.GetDataSetScroll(scope)
If dss.IsEmpty Then Exit...
Do
    dim val as Object = dss.CurrentRow.Item("colName")
Loop Until Not dss.MoveNext



 
Old April 18th, 2005, 01:02 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter,

I tried using dataset and good news, it works. Thanks again for your suggestion.

Cheers!

Quote:
quote:Originally posted by planoie
 There is no RecordSet object in ADO.NET and therefore no NextRecordset method.

Instead, you would normally use a DataSet which can hold multiple tables. I know that in the ADODB world you can tack two queries together with ; and the result will be a single ADODB.RecordSet object where you use NextRecordSet to advance. I don't know if there is an equivalent in ADO.NET.

-Peter
 
Old April 18th, 2005, 01:07 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Candle,

I just used Dataset instead of DataReader object and good news, it works properly. Anyway, thanks for your help.

Cheers!

Quote:
quote:Originally posted by lsxx
 try DataReader Object£¡
I think this can help you

Candle
 
Old April 20th, 2005, 07:54 AM
Authorized User
 
Join Date: May 2004
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default

With DataSet object you can use multiple queries separated by semicolons. And you'll get the DataSet populated with all the tables you selected. That is, if you specify three queries, you get three tables, namely Table, Table1, Table2 into your DataSet.

ejan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Find Method of ADO martinaccess Access 3 November 21st, 2007 07:35 AM
Difference between ADO and ADO.NET rakeshclose2u ADO.NET 2 April 23rd, 2007 03:57 AM
Nextrecordset mikedeepak Classic ASP Professional 1 April 28th, 2006 04:29 PM
XL2000: Query Table’s Refresh method with ADO Rod the mod Excel VBA 3 April 5th, 2005 01:28 PM
ADO DELETE METHOD JENKINSACTIVE SQL Server 2000 4 November 4th, 2004 04:58 AM





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