Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single Record IN a recordset

Status
Not open for further replies.

Kinl

Programmer
Mar 19, 2001
168
US
Hi all,

I'm having a problem with a recordset that returns one record. I want it to return one record but when I go to read that value like this:
myVariable = objRS("numb")
I get an error stating that the recordset was at the BOF or EOF and it doesnt work. I cant read the value, but if i do a objRS.RecordCount on it, it will return a positive one. Therefore the record is there, but I cant read from it.
I created a program in VB, and it works fine in VB, I can read the value and so forth but when I do the same code in ASP (VBScript) it doesnt want to work.
Any ideas?

shorty
 
Heres the Error I get:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
 
Try this before trying to access the value.

Code:
objRS.MoveFirst

If that still throws a BOF / EOF error, then there are not any records in that recordset. Check your SQL.

ToddWW :)
 
Let me know if that throws a different error. We may need to change the recordset type before you can move the pointer like that ..

ToddWW :)
 
It throws an exception error stating that it cannot do that.

I dont know how but I Fixed it, by messing around with it. I know there was a record in it, but i couldnt access it somehow.

set objRS = Server.CreateObject("ADODB.RecordSet")
SQL="exec sp_GetShipCount " & varItem.sku & "," & CustID
objRS.open SQL, objConn,2,3
If Not (objRS.EOF and objRS.BOF) THEN ShpCnt = clng(objRS("numb")) Else ShpCnt=0 END IF

It assigns the value now. I dont know why it didnt before.
I added the IF statement in bold and now the value gets assigned.

I wrote this code before and I dont remember it working. Maybe I forgot the 'NOT' portion. I dont know.

Thanx for the help though!

shorty

 
Yeah !! Forgetting the NOT portion would definitely do it.

I'm glad that you got it working :)

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top