SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 18th, 2000, 09:20 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
Problems with SQL select and RecordCount

<i><b>Originally posted by : Clueless (aspfree@anwaltonline.com)</b></i><br /><br />I would like to select a certain number of records from a list with a SQL select.<br />After this I would like to know how many records are in this selection. For some reason this turns to be -1. What do I need to change?<br /><br />The lines are:<br />strSQL = "SELECT * FROM links WHERE CatID = " & CatID & " AND Member = " & MemberShow & " ORDER BY Name ASC; "<br />Set objRecord = objConn.Execute (strSQL)<br /><br />A recordcont on objRecord turns -1.<br /><br />Any help is appreciated.<br />

Reply With Quote
  #2  
Old December 19th, 2000, 07:33 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : </b></i><br /><br />Try fetching records through recordset & put cursortype as adOpenStatic<br /><br />------------<br />Clueless at 12/18/2000 7:20:46 AM<br /><br /><br />I would like to select a certain number of records from a list with a SQL select.<br />After this I would like to know how many records are in this selection. For some reason this turns to be -1. What do I need to change?<br /><br />The lines are:<br />strSQL = "SELECT * FROM links WHERE CatID = " & CatID & " AND Member = " & MemberShow & " ORDER BY Name ASC; "<br />Set objRecord = objConn.Execute (strSQL)<br /><br />A recordcont on objRecord turns -1.<br /><br />Any help is appreciated.<br />

Reply With Quote
  #3  
Old September 30th, 2003, 06:58 AM
m_lazor m_lazor is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Luxembourg
Posts: 156 m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
A recordset that was just opened has no defined cursor position. It also does not know how many recordss are in the recordset unless you jumpt to it's end (sounds logic, no?) Hence, you need to:

rs.MoveLast
rs.MoveFirst

msgbox rs.recordcount

This gives the correct result

Reply With Quote
  #4  
Old October 9th, 2003, 06:43 AM
lvramani lvramani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 14 lvramani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Use the cursor type as adOpenKeySet.

This will get the number of records in the table.

But if you cannot change the cusrsor type for any reason follow the given alternative:-
x=0
Do while rs.eof = false
Your ASP code
rs.MoveNext
x = x + 1
Loop
Once you come out of the Loop then the variable x will contain the number of records

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Problems with SQL select and RecordCount


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway