|
 |
asp_web_howto thread: need help
Message #1 by "Rola Ali" <rola_ali@h...> on Sun, 16 Sep 2001 07:34:38 +0000
|
|
Hi,
Actually Iam beginner in coding ASP, Iam now developing simpel application,
I read the Active server pages book for the beginners, bue I still have
question wihsing u will help me.
My question is when I open recordset imagine Iam using Oracle Database how
can I know the no. of records in the table Iam going to open, in the book I
read I can use something called
objectrecordsource.recordcount but it didn't work with me it just give me -1
whenever I tried to know the no. of records.
that's all, wishing u can help me.
thanks in advance,
best regards,
Rola
Message #2 by Anupama Nallari <ANallari@p...> on Sun, 16 Sep 2001 08:48:27 -0500
|
|
Hi ,
That generally happens if your recordset is empty. Just check that your
recordset has records by using the following code
if recordset.eof <> false then
response.write objectrecordsource.recordcount
end if
if there are records in the recordset then this should give you the number
of records.
Thanks,
Anu
Message #3 by "Walter Franssen" <walter@w...> on Mon, 17 Sep 2001 07:39:20
|
|
Just do this before you open je connection
RS.CursorLocation = 3
Example:
StrQry = "SELECT * FROM lam"
RS.CursorLocation = 3
RS.Open StrQry, conn
iRecordcount = RS.recordcount
Just try it
Message #4 by "Ken Schaefer" <ken@a...> on Mon, 17 Sep 2001 16:46:51 +1000
|
|
Yes and No,
You are setting the cursor location to adUseClient - this means you are
using an adOpenStatic cursor type, since all client-side cursors are
adOpenStatic. adOpenStatic and adOpenKeyset return the correct recordcount,
thus you can get the recordcount by using the default adUseServer
cursorlocation, but just using the "correct" cursortype.
http://www.adopenstatic.com/faq/recordcounterror.asp
That said, I believe there are better alternatives to .RecordCount
http://www.adopenstatic.com/faq/recordcountalternatives.asp
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Walter Franssen" <walter@w...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Subject: [asp_web_howto] Re: need help
: Just do this before you open je connection
:
: RS.CursorLocation = 3
:
: Example:
:
: StrQry = "SELECT * FROM lam"
: RS.CursorLocation = 3
: RS.Open StrQry, conn
:
: iRecordcount = RS.recordcount
:
: Just try it
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |