PP3000
PP3000

Reputation: 11

Syntax error in From clause (easiest from clause possible)

I have an error in my easiest From clause (ErrorCode: -2147217900) and I do not know why...

Here my Code:

    static string ConnString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=E:\\P-OT-MT\\P-OT-DB.accdb; Jet OLEDB:Database Password=*************;";
    public static DataSet DS_USERS;

    public static void INIT_DS()
    {
        // Initialize the USERS dataset and write the database information to it
        DS_USERS = new DataSet();
        string SQL = "SELECT * FROM USER;";
        using (OleDbConnection Conn = new OleDbConnection(ConnString))
        {
            Conn.Open();
            OleDbCommand cmd = new OleDbCommand(SQL, Conn);
            OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
            adapter.Fill(DS_USERS);

            cmd.Dispose();
            adapter.Dispose();
            Conn.Close();
        }
    } 

I dont get where the error is... the Table USER is existant and the location of the Database is also correct... The password is correct too...

I hope you can help me

Upvotes: 1

Views: 403

Answers (1)

Flakes
Flakes

Reputation: 2442

USER is a reserved word in MS Access.

See: List of reserved words in Access 2002 and in later versions of Access

You have to escape the word using [].

Use: string SQL = "SELECT * FROM [USER];";

Upvotes: 2

Related Questions