DataReader (RecordsAffected)

Results 1 to 2 of 2

Thread: DataReader (RecordsAffected)

  1. #1
    Join Date
    Dec 1969

    Default DataReader (RecordsAffected)

    Hi all,<BR><BR>I can&#039;t seem to get the RecordsAffected property of the DataReader to work.<BR><BR>Dim objReader As OleDbDataReader<BR><BR>objReader = objCmd.ExecuteReader<BR>Response.Write(objReader.R ecordsAffected)<BR><BR>No error message is given, but it always returns 0 whether there is data or not. What I want to do is check if any data is exists before I bind it to a control.<BR><BR>Thanks,<BR>D.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: DataReader (RecordsAffected)

    DataReaders cannot determine the amount of records being returned. I think the RecordsAffected Property is for something else. <BR><BR>The reason for this is because DataReaders fetch only one record at a time. WHen you call the Read() Method it simply looks for another record and returns true if there was one. When you first get it there is no way to tell if you have no data or 20 records. One way I found to get around this limitation... ( im not sure if this will apply to you). Is to bind whatever your binding (repeater,datagrid,datalist) And then check the item count when done. It may not help if your paging. Or just use a dataset.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts