Results 1 to 7 of 7

Thread: Equivalent of Rs.Recordcount and RS.EOF

  1. #1

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Equivalent of Rs.Recordcount and RS.EOF

    Hi there!
    What is the equivalent of Recordset.Recordcount and Recordset.EOF in ASP.net?
    For ex. how do I know, whether a DataReader has record(s) or not?
    J£ßä

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    The .EOF property was replaced by a function call: DataSet.Read(), so:
    VB Code:
    1. Do While DataSet.Read()
    2.     'Your code here
    3.   Loop

    RecordCount:
    VB Code:
    1. MsgBox("Record Count = " & DataSet.Tables("TableName").Count

  3. #3

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265
    Hi axion_sa ,
    Thanks for the quick reply. but is there anyway can I avoid the while loop to know?
    J£ßä

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    This should help a little:

    VB Code:
    1. Dim dt As DataTable
    2.   Dim dr As DataRow
    3.   Dim dc As DataColumn
    4.  
    5.   For Each dt In ds.Tables 'Where ds is a DataSet
    6.     For Each dr In dt.Rows
    7.       For Each dc In dr.Columns
    8.         Console.WriteLines(dr(dc))
    9.       Next dc
    10.     Next dr
    11.   Next dt

  5. #5
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    Seems to be some confusion about what is being talked about here. I pretty sure the question was about datareader and not datasets.

    If Datareader.Read then
    'the datareader contains a resultset.

  6. #6

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265
    Hi Musician!
    Thanks for the reply. I still have one doubt.

    Assuming my recordset has fetched just one record, and if I use the following code,
    --------------
    If Datareader.Read then
    --------------

    The resulset now would have come to the EOF no?[Since Datareader.Read is identical to RS.MoveNext]
    J£ßä

  7. #7
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    It is similar to MoveNext except for the fact that it is not on the first record until the first call to the read method.

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