ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old December 11th, 2002, 05:29 PM
stevea stevea is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Vancouver, BC, Canada
Posts: 1 stevea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RecordCount with adOpenStatic = -1

Hi All,

I'm having a hell of a time with this...

From researching multiple websites, specifying the asOpenStatic cursor should return the correct RecordCount.

Here is my code:

sql = "SELECT UserID,UserName,Password,AccessLevelID,LockThreshold,Active FROM tbl_users WHERE UserName = '" & username & "' and Password = '" & password &"' "

set rs_login=Server.CreateObject("ADODB.Recordset")
rs_login.Open sql, conn, adOpenStatic', adLockReadOnly, adCmdTable

if rs_login.RecordCount <> 0 then

Response.Write("Login Successful" & "<br>")
Response.Write("Record Count: " & rs_login.RecordCount)

end if

I know I can use the select count(*) instead, but I've been researching this for quite some time now and I would like to know what's wrong.

Thx,

Reply With Quote
  #2  
Old December 11th, 2002, 09:48 PM
escapist escapist is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 2 escapist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Why not use

If YourRecordSet.EOF Then
response.Write "Sorry No Records Found"
Else
'Output of Records found
End If

?????????

Reply With Quote
  #3  
Old December 24th, 2002, 07:58 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
Just a simple question, but have you defined the variable adOpenStatic in your asp pages? adOpenStatic isn't defined by default, you have to define it a) yourself or b) include adodb.inc which is available from microsoft which defines all ADODB constants.


Dim lRS: Set lRS = CreateOBject("ADODB.RecordSet")
lRS.Open lCmd, , adOpenStatic

Response.Write lRS.RecordCount

-> w/o definition of adOpenStatic (which is then the same as "") it returns -1

if i do adOpenStatic = 3 and the execute it, it returns the valid RecordCount.

Reply With Quote
  #4  
Old December 26th, 2002, 01:47 AM
escapist escapist is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 2 escapist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I use the .inc file from MS.

Reply With Quote
  #5  
Old December 26th, 2002, 06:54 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
Code:
<%
    Dim lConn
    Set lConn = CreateObject("ADODB.Connection")

    lConn.ConnectionString = "Provider=SQLOLEDB.1;User ID=username;Password=password;Data Source=hostname;Initial Catalog=database"
    lConn.Open

    Dim lRS
    Set lRS = CreateOBject("ADODB.RecordSet")
    lRS.Open "SELECT * FROM TTodo", lConn, 3

    Response.Write lRS.RecordCount
%>


Perhaps your provider/driver doesn't support adOpenStatic? Which driver are you using and which database?

Reply With Quote
  #6  
Old August 28th, 2003, 05:01 AM
faithBHP faithBHP is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Slovenia
Posts: 1 faithBHP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
cursorLocation

there are some properties, that are not supported on mySQL server; one of such is adUseServer cursorLocation for counting the total of affected rows.
if you use adUseServer cursorLocation, you will get -1 as a number of affected rows, no matter what (even, if you properly open the connection, ie. adOpenStatic)

right solution is to use adUseClient cursorLocation. Here is a sample snippet of code:

MyConn = ...connectionString...
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open MyConn, "", ""
Set RS = Server.CreateObject("ADODB.Recordset")
pogoj = "SELECT * FROM database"
RS.CursorLocation = adUseClient
RS.Open pogoj, Conn, adOpenStatic, adLockOptimistic
counter = RS.RecordCount

hope, this will help

Last edited by faithBHP : August 28th, 2003 at 05:05 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > RecordCount with adOpenStatic = -1


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 5 hosted by Hostway