hi.im facing an error that says 'syntax error in FROM clause'.i dont know where i went wrong because it used to run smoothly.from my research about this error,it seems each solution is unique,it doesnt relate to what im doing.can anyone please help?here are my codes:

Private Sub Cmd_Login_Click()
Adodc1.RecordSource = "SELECT * FROM User Where user_name='" & Txt_Name.Text & "'"
Adodc1.Recordset.Requery
Adodc1.Refresh

If Adodc1.Recordset.RecordCount = 0 Then 'user doesnt exist
    MsgBox "Bad Username! Try again."
    Exit Sub 'so that it won't move on checking the password
End If

'user exist,check password
If Adodc1.Recordset.Fields("password") = Txt_Pass.Text Then
    If Adodc1.Recordset.Fields("user_status") = "admin" Then 'check user status
    'current_user = Adodc1.Recordset.Fields("user_name").Value
    MsgBox "Login Successful!"
    Unload Me
    A2_AdminMain.Show 'login Admin Page
    Else
    current_user = Adodc1.Recordset.Fields("user_name").Value
    MsgBox "Login Successful!"
    Unload Me
    A2_UserMain.Show 'login user page
    End If

Else 'Wrong Password
    MsgBox "Wrong password. Try again."
End If

End Sub

Recommended Answers

All 8 Replies

Try this:

Adodc1.RecordSource = "SELECT * FROM [User] Where user_name='" & Txt_Name.Text & "'"

If that doesn't work, check the table name 'User' is correct in your database.

The keyword User might not be supported, check for that in the databse that u are using.

i got it.i change the name of my table from: 'User'->'Table_user' in my database.
it works fine.why does this happen?is the keyword 'user' a special case?

yup! we can't use user as table name in database because it's already exist.

i think it was used to store the data about users of database development software (such as sql server) , for example: login name that we use to login to the sql server..

USER is a restricted key word. Most of the databases do not support any object by this name.

i faced the same problem 2.using the name 'user' as a table name doesnt work.i tried searching for ways to overcome but failed.n now i know why.thanx evryone;)

rumi tnx for the code.. it really helped my system.. :)

holly.. tnx!! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.