Search code examples
databasec#-2.0accessdatasource

Syntax error in FROM clause Access


I want to read the data from Access Database in order to check if a password is correct or not. I use this code:

var check=false;
OleDbCommand c = new OleDbCommand();
c.Connection = co //the connection to the Database;
c.CommandText = "select * FROM User Where user_name='"+usee+"'"; 
OleDbDataReader re = c.ExecuteReader();
while (re.Read())
{
    if (re.ToString() == pasy)
    {
        check = true;
    }
}

It gives me a "Syntax error in FROM clause." when the code executes.


Solution

  • "User" is a reserved word for Access.

    Here is a list of reserved words : http://support.microsoft.com/kb/286335/en-us

    and here is a page describing that problem : http://support.microsoft.com/kb/181489/en-us