Blarcevurcerf
New Member
Hi all,<BR><BR>I can'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.RecordsAffected)<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>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.