|
-
Jan 10th, 2002, 12:08 AM
#1
Thread Starter
PowerPoster
DAO problem...
I posted this in General VB, but I'll post it here too.
I am having problems with DAO. I have this same code in a different project, and it works fine, but I am trying to use the same code in a different program to open a table and get info out of it.
OK this code works fine, to get an item out of the table:
VB Code:
Set db = OpenDatabase("C:\Windows\Desktop\inventory.mdb")
strSQL = "SELECT * FROM Current WHERE ID = " & txtID.Text
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then
'Text1.Text = rs!ItemNo & "" 'substitute real field names
buff = rs!Price '& ""
lstReceipt.AddItem buff
txtID.Text = ""
Else
MsgBox "No Match found for that ID.", vbCritical
End If
rs.Close
db.Close
But then I use this code to get info out of a different database and table:
VB Code:
Private Sub cmdLogin_Click()
Uname = txtUsername.Text
Pword = txtPassword.Text
Set db = OpenDatabase("C:\Windows\Desktop\users.mdb")
MsgBox "got here"
strSQL = "SELECT * FROM usertable WHERE Username = " & Uname
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount = 0 Then MsgBox "No user by the name " & Uname & ". Please check the name you entered.", vbInformation: Exit Sub
TestPass = rs!Password
If TestPass = Pword Then MsgBox "Correct password!"
rs.Close
db.Close
End Sub
and I get an error with the dbOpenDynaset variable. It says somthing about Too few parameters, expected 1. So I change dbOpenDynaset to a 1, and it gets an error opening the table. This is frustrating! Just incase you are wondering, I HAVE added a reference to the ADO library, just like in the other project, and I have declared all my variables... I just don't want to post all the code.
Please don't mention ADO, cause I have had so many f**king problem with ADO, it's not even funny.
Thanks in advance
-Joey
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
|