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

login screening converting from DAO to ADO

P: 84
Ok i have a working login screen on my project but its running the old DAO / data object style, but the rest of my project is is ADO / SQl ( i think :0 )

This is what i have for the new ADO

Expand|Select|Wrap|Line Numbers
  1. Public UserRS As New ADODB.Recordset
  2. Public UserCONN As New ADODB.Connection
  3. Public UserSQL As String ' global sql string
  4. Public HoldUser As String
Expand|Select|Wrap|Line Numbers
  1.  Function ConnectUser() 
  2. Dim UserSQL As String
  3. Set UserCONN = New ADODB.Connection
  4. If UserCONN.State = 1 Then
  5. UserCONN.Close
  6. End If
  7. MSDatabaselogin = App.Path & ("\login.mdb")
  8. UserSQL = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MSDatabaselogin & ";Persist Security Info=False"
  9. UserCONN.Open (UserSQL), , , 0
  10. End Function
  11.  
  12. Function OpenUserDB(UserSQL As String)
  13.  
  14. ConnectUser
  15.  
  16. Set UserRS = Nothing
  17. If UserRS.State = 1 Then
  18. UserRS.Close
  19. End If
  20.  
  21. UserRS.CursorLocation = adUseClient
  22. UserRS.Open UserSQL, UserCONN, adOpenDynamic, adLockOptimistic
  23. End Function
  24.  
And this is on the login command button

Expand|Select|Wrap|Line Numbers
  1.  
  2. UserSQL = "SELECT * FROM User"
  3. OpenUserDB (UserSQL)
  4. If (UserRS("Userid") = Text1.Text) And (UserRS("password") = Text2.Text) Then
  5. Form1.Hide
  6. Main_menu.Show
  7. Main_menu.Caption = "Welcome user..."
  8. Timer1.Enabled = True
  9.  
  10. 'Permissions
  11. Main_menu.mnu_Admin.Enabled = False
  12. '-----------
  13.  
  14. Exit Sub
  15.  
  16. End If
  17. Exit Sub
  18.  

It comes up with an errors saying "Syntax in Error FROM clause"
then highlights

Expand|Select|Wrap|Line Numbers
  1. UserRS.Open UserSQL, UserCONN, adOpenDynamic, adLockOptimistic
Can anyone give any suggestions why this is happening ?
Dec 3 '07 #1
Share this Question
Share on Google+
5 Replies


debasisdas
Expert 5K+
P: 8,127
User is a reserved keyword and can't be used in sql statments. If you have a table named user ,rename it to somthing like apps_user or somthing more meaningful.
Dec 6 '07 #2

P: 84
ok ill have a look at that.
Dec 6 '07 #3

P: 84
thx that worked, btw is there a list anywhere that shows all the reserved words for vb ? if so then it would hopefully prevent this from happening again :)
Dec 6 '07 #4

debasisdas
Expert 5K+
P: 8,127
user is a keyword in database not in vb.
Dec 6 '07 #5

P: 84
user is a keyword in database not in vb.
...well for acces then
Dec 6 '07 #6

Post your reply

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