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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Query

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Just starting to look at ASP and have got a stupid problem. when using the following code, i am not getting the expected value returned.

strGetMax ="Select MAX(NewsID) as maxID FROM tblNews
objCheck.Open strGetMax
if ((objCheck.RecordCount = 0) OR (objCheck("maxID") ="")) then
maxIDVal =1
else
maxIDVal = objCheck("maxID") +1
end if

when there are no records in the table, nothing is assigned to maxIDVal, when there is a record in the database it works fine. quite where this null value is coming from i don't know ! I have found that i am getting a -1 returned as the recordcount when there are no records in the db. any ideas ?
 
check out paul's faq on recordset properties
faq333-618

you need to define the cursor as one that has movement eg:adOpenStatic etc...

his FAQ should clear it right up for you.

good luck
leo
 
If you do this:

objCheck.Open strGetMax, 3, 3

It will allow you to use the recordset. You have to have the proper cursor set when you open the recordset otherwise .recordcount will return -1. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I remember having problems with testing for recordcount = 0 so to avoid the problem I would just test for recordcount<1 and that usually resolved my issues. I know I read in the help files (Interdev) that it should be 0 if no records are returned but that test never worked properly for me.

Hope this helps Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top