|
-
Nov 28th, 2001, 10:34 AM
#1
Thread Starter
Hyperactive Member
recordset
Can anyone tell me why my code doesn't work...
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID=userName", dbOpenDynaset)
username is a string defined previously ("Brian").
thanks
-
Nov 28th, 2001, 10:36 AM
#2
Frenzied Member
Re: recordset
Originally posted by 2000a
Can anyone tell me why my code doesn't work...
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID=userName", dbOpenDynaset)
username is a string defined previously ("Brian").
thanks
try Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & ''", dbOpenDynaset)
-
Nov 28th, 2001, 10:42 AM
#3
Thread Starter
Hyperactive Member
it returns 1... I have 6 records with that username...
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & "'", dbOpenDynaset)
-
Nov 28th, 2001, 10:44 AM
#4
Frenzied Member
What's userid in your database? an autonumber?
-
Nov 28th, 2001, 10:47 AM
#5
Frenzied Member
Originally posted by 2000a
it returns 1... I have 6 records with that username...
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & "'", dbOpenDynaset)
did you forget to loop through the record?
[Highlight=VB]
do until rs2.eof
msgbox rs2("Username")
loop
[/vbvode]
-
Nov 28th, 2001, 10:47 AM
#6
Frenzied Member
Originally posted by 2000a
it returns 1... I have 6 records with that username...
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & "'", dbOpenDynaset)
did you forget to loop through the record?
VB Code:
do until rs2.eof
msgbox rs2("userID")
loop
-
Nov 28th, 2001, 10:47 AM
#7
Thread Starter
Hyperactive Member
sorry,
the rs2 is working, but: rs2.RecordCount is only returning one record...
I printed the userNames with a do while and they all show...
How can I count without a loop?
thanks
-
Nov 28th, 2001, 10:49 AM
#8
Frenzied Member
Originally posted by 2000a
sorry,
the rs2 is working, but: rs2.RecordCount is only returning one record...
I printed the userNames with a do while and they all show...
How can I count without a loop?
thanks
.recordcount is not accurate if your using
dbOpenDynaset
you have to use OpenStatic or the other ones ( i forgot which one)
but i wouldnt recommend using .recordcount cus it still loops through the records..
-
Nov 28th, 2001, 10:58 AM
#9
Thread Starter
Hyperactive Member
Now i'm having trouble with:
Set rs2 = db.OpenRecordset("SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & "' AND tblLicenses.appName='" & appName & "'", dbOpenDynaset)
What's wrong with the AND?
thanks
-
Nov 28th, 2001, 11:03 AM
#10
Frenzied Member
whats the error yoru getting?
-
Nov 28th, 2001, 11:12 AM
#11
Thread Starter
Hyperactive Member
too few parameters. expected 1
-
Nov 28th, 2001, 11:15 AM
#12
Frenzied Member
VB Code:
Dim SQL as string
SQL = "SELECT * FROM tblLicenses WHERE tblLicenses.userID='" & userName & "' AND tblLicenses.appName='" & appName & "'"
msgbox SQL
Set rs2 = db.OpenRecordsetdb(SQL, OpenDynaset)
see what that prints out first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|