Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 recordcount = -1 when using access queries
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flaimo
New Member

Austria
72 Posts

Posted - 03 May 2001 :  11:19:23  Show Profile  Visit Flaimo's Homepage  Send Flaimo an AOL message  Send Flaimo an ICQ Message  Send Flaimo a Yahoo! Message
i changed a couple of sql statemants in my asp files to access queries. now i always get -1 when using recordcount. i know i have to use "adOpenStatic" somehow, but i don't know how to do it here, since i'm not using "RS.Open", but the "execute"



that's what the query in access looks like:


PARAMETERS [@person] Text ( 255 );
SELECT DISTINCT bilder.unterkategorie, bilder.unterkategorie_e,
bilder.Name_e, bilder.Name
FROM bilder
WHERE (((bilder.Name)=[@person])) OR (((bilder.Name_e)=[@person]))
ORDER BY bilder.unterkategorie, bilder.unterkategorie_e;


---------------------------------------------------------
that's whats in the asp file:



SET nameConn3 = Server.CreateObject("ADODB.Connection")
nameConn3.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("../dbanken/bilder.mdb")


tempex = "exec query_unterkat '" & person & "'"
SET pickat = nameConn3.Execute(tempex)



IF pickat.RecordCount <> 0 THEN

WHILE NOT pickat.EOF

<a href=show_gallery.asp?person=" & Server.URLEncode(person) & "&kat="
& Server.URLEncode(pickat("unterkategorie_e")) & "&MOVE=1>" &
pickat("unterkategorie_e") & "</a><br>"

pickat.MoveNext
WEND

END IF


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


if i try it that way:


SET pickat = Server.CreateObject("ADODB.RecordSet")

tempex = "exec query_unterkat '" & person & "'"
pickat.open nameConn3, tempex, 3, 3


i get an error which says something about arguments are out of range or wrong type. i only have the german error message, sorry:

"Die Argumente sind vom falschen Typ, liegen außerhalb des
Gültigkeitsbereiches oder sind miteinander unvereinbar."

Edited by - flaimo on 03 May 2001 11:20:40

Doug G
Support Moderator

USA
6493 Posts

Posted - 03 May 2001 :  13:00:37  Show Profile
As far as I know, if you use conn.execute(sql) you will get a forward-only cursor, so recordcount won't work. You could add a SELECT COUNT(*) as myCount perhaps.

======
Doug G
======
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 03 May 2001 :  15:02:23  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
try this page for an example...

http://www.freeaspcode.net/freeaspcode/code/asp/segments/code/sql_server_count_records.asp?pg=2

Brad
Go to Top of Page

Flaimo
New Member

Austria
72 Posts

Posted - 03 May 2001 :  17:52:35  Show Profile  Visit Flaimo's Homepage  Send Flaimo an AOL message  Send Flaimo an ICQ Message  Send Flaimo a Yahoo! Message
i know that i could solve it with a second RS (i do so now) but if it isn't really necessary, i want to avoid that solution.
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 03 May 2001 :  17:57:53  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
no need for a second recordset, just do like this...


strSql = "SELECT Prod_ID, "
strSql = strSql & "Prod_Cag_ID, "
strSql = strSql & "Count(Prod_ID) As Tot, "
strSql = strSql & "Prod_Name, "
strSql = strSql & "Prod_Description, "
strSql = strSql & "Prod_Price, "
strSql = strSql & "Prod_Picture_URL "
strSql = strSql & " FROM ExhibitParts_Store_Products"
strSql = strSql & " WHERE Prod_Cag_ID='" & Request.QueryString("cag_id") & "'"
strSql = strSql & " AND Prod_ID='" & Request.QueryString("prod_id") & "'"
strSql = strSql & " ORDER BY Prod_Name ASC"
set rs = my_Conn.Execute (strSql)


Then Tot would hold the amount of records

Brad
Go to Top of Page

Huntress
New Member

USA
96 Posts

Posted - 03 May 2001 :  18:42:34  Show Profile  Visit Huntress's Homepage
I had to do this in a VB program today... hmmm what a coincidence!

recordcount only shows the current record, so you have to movelast, then recordcount, and then movefirst to start processing.

Diana

Go to Top of Page

Flaimo
New Member

Austria
72 Posts

Posted - 04 May 2001 :  08:52:28  Show Profile  Visit Flaimo's Homepage  Send Flaimo an AOL message  Send Flaimo an ICQ Message  Send Flaimo a Yahoo! Message
oh well, if there is no better way then i just use a second query to get the number of RS
Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 04 May 2001 :  09:01:03  Show Profile  Visit Kat's Homepage
why not do what redbrad suggested, rather than creating another unnecessary Recordset Object?

KatsKorner
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000 Version 3.4.07