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?
Printable View
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?
The .EOF property was replaced by a function call: DataSet.Read(), so:
VB Code:
Do While DataSet.Read() 'Your code here Loop
RecordCount:
VB Code:
MsgBox("Record Count = " & DataSet.Tables("TableName").Count
Hi axion_sa ,
Thanks for the quick reply. but is there anyway can I avoid the while loop to know?
This should help a little:
VB Code:
Dim dt As DataTable Dim dr As DataRow Dim dc As DataColumn For Each dt In ds.Tables 'Where ds is a DataSet For Each dr In dt.Rows For Each dc In dr.Columns Console.WriteLines(dr(dc)) Next dc Next dr Next dt
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.
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]
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.