Saturday, February 25, 2012

Avoiding EOF Error

I am querying a sql server db from asp/ado. I am trying to get data from a list of people but all of them may not have the data I am looking for. As a result, when the query gets to that person/record, I get the message:

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

How can I avoid this message? Here is my code:

sql="SELECT TrngDate, Effort, UnitMeas FROM TrainingData WHERE PartID = " & CLng(iPartID)

Set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1, 2

Do While Not rs.eof
.
.
.
rs.MoveNext
Loop

I also used the conn.Execute approach.

This a recurring issue for me. Any ideas?Check this KBA (http://support.microsoft.com/default.aspx?scid=kb;en-us;230101) and get the fix if required.

Also check whether that would be a closed recordset while error was returned. And also check whether second RS is opened/returned.|||Originally posted by Satya
Check this KBA (http://support.microsoft.com/default.aspx?scid=kb;en-us;230101) and get the fix if required.

Also check whether that would be a closed recordset while error was returned. And also check whether second RS is opened/returned.

But it doesn't appear that the problem referred to is my issue. My issue is that the record that I am looking for may in fact not exist. I am not sure how to determine that before 'looking' for it. Is there any way I can get a record count? In the past I have tried this and it returns a recordcount of -1.|||In that case while opening of RS just count from the table and use the variable to avoid it.|||Originally posted by Satya
In that case while opening of RS just count from the table and use the variable to avoid it.

but I don't understand how that would look syntactically. Could you show me the code?

Thanks!|||Dont' be sorry..

Rather I fee so, (Im no developer :( )
Still check this webpage (http://www.vbcode.com/asp/showsn.asp?theID=4816) for code example.

No comments:

Post a Comment