By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,779 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,779 IT Pros & Developers. It's quick & easy.

can not lo gon

P: 10
i am running an application that use vb in conjuction with sql
using the following code to log on will give me the following error:
runtime error 2147220999 (800401f9) method of object connection current project failed pointing to the following error:
rs.Open str_sel, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

i used the following code:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub ACCEPT_Click()
  4. Dim ls_username, ls_username_1, ls_password, ls_password_1  As String
  5. Dim str_sel As String
  6. Dim rs As Recordset
  7. Dim rs_count As Integer
  8. ls_username = Me.User_name.Value
  9. ls_password = Me.password.Value
  10.  
  11.  
  12.  
  13. str_sel = "SELECT * FROM USERS WHERE [USERNAME] = '" & ls_username & "';"
  14. If IsNull(ls_username) Then
  15. MsgBox "Please enter username", vbInformation, "Payroll Logon"
  16. Else
  17. Set rs = New ADODB.Recordset
  18. rs.Open str_sel, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  19.  
  20. rs_count = rs.RecordCount
  21. If rs_count < 1 Then
  22. MsgBox "Username Does not exist", vbCritical, "Payroll Logon"
  23. Else
  24. ls_password_1 = rs!password
  25. If ls_password_1 <> ls_password Or IsNull(ls_password) Then
  26. MsgBox "Please Enter Correct Password ", vbCritical, "Payroll Logon"
  27. Else
  28. gsusername = rs!Username
  29. gsprofile = rs!Profile
  30. gl_Full_name = rs!Full_name
  31. DoCmd.Close
  32. End If
  33. End If
  34. DoCmd.OpenForm "main", acNormal
  35. End If
  36.  
  37. End Sub
Apr 16 '07 #1
Share this Question
Share on Google+
6 Replies


iburyak
Expert 100+
P: 1,017
It looks like your ODBC drivers don't work.
To test it, try to create DSN to your server and at the end it has option to test connection. If it doesn't work you probably need to update\restore your ODBC drivers.
Usually helps to install latest MDAC from Microsoft.


Thank you.
Apr 16 '07 #2

P: 10
It looks like your ODBC drivers don't work.
To test it, try to create DSN to your server and at the end it has option to test connection. If it doesn't work you probably need to update\restore your ODBC drivers.
Usually helps to install latest MDAC from Microsoft.


Thank you.

i have already tested and connection is successfull
im have also installed Mdac 2.8 but it doesnt work
Apr 19 '07 #3

P: 1
you need to connect to the database first before trying to get a result set into the recordset.

dim con as new adodb.connection
dim rs as adodb.recordset
.
.
.
' using a DSNless connection, connect to the database
con.open "Provider=SQLOLEDB.1;Password=p@55w0rd;Persist Security Info=True;User ID=UserName;Initial Catalog=DatabaseName;Data Source=ServerName"

'' given your previous assisgnment to str_sel, you can use....
rs = con.execute(str_sel)

although I have come to find out the adodb 2.8 class does not return a correct value in the recordcount method.

you may need to iterate through the recordset manually to get a correct count of records returned.
Apr 19 '07 #4

P: 10
have tried the code but still no change
itsa still gives me the same error
Apr 20 '07 #5

iburyak
Expert 100+
P: 1,017
Did you check in project - references ADO?

Show your code now.
Apr 20 '07 #6

Expert 5K+
P: 8,434
The following was sent by msspn, apparently by hitting the Report button instead of Reply (hey people, ya gotta watch that)...

i have managed to solve the problem. i upgraded my operating system using Windows XP SP1
that was al i did
Aug 3 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.