Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Employee'

Open Alassace opened this issue 4 years ago • 1 comments

Screenshot (18) private void setConnection() { sql_con = new SQLiteConnection("Data Source = DBEmployeeManagement.db;Version = 3; New = False;Compress=True"); }

    private void ExecuteQuery(string txtQuery)
    {
        setConnection();
        sql_con.Open();
        sql_cmd = sql_con.CreateCommand();
        sql_cmd.CommandText = txtQuery;
        sql_cmd.ExecuteNonQuery();     
        sql_con.Close();
    }
    private void LoadData()
    {
        setConnection();
        sql_con.Open();
        sql_cmd = sql_con.CreateCommand();
        string CommandText = "SELECT * FROM Employee Profile ";
        DB = new SQLiteDataAdapter(CommandText, sql_con); \\this starts the error
        DS.Reset(); \\
        DB.Fill(DS);\\
        DT = DS.Tables[0];
        dataGridEmp.DataSource = DT;

        cbGender.DataSource = DT;

        string CommandText1 = "SELECT * FROM Department Profile";
        DB1 = new SQLiteDataAdapter(CommandText1, sql_con);
        DS1.Reset();
        DB1.Fill(DS1);
        DT1 = DS1.Tables[0];
        dataGridDept.DataSource = DT1;

        cbDept.DataSource = DT1;

        string CommandText2 = "SELECT * FROM Job Profile";
        DB2 = new SQLiteDataAdapter(CommandText2, sql_con);
        DS2.Reset();
        DB2.Fill(DS2);
        DT2 = DS2.Tables[0];
        dataGridJob.DataSource = DT2;

        cbJob.DataSource = DT2;

Alassace avatar Sep 09 '21 06:09 Alassace

In the query, you write, SELECT * FROM Employee Profile If you want to query in the Employee table then the query should be SELECT * FROM Employee

If you want to query in the EmployeeProfile table then the query should be SELECT * FROM EmployeeProfile

khairuzzaman avatar Sep 13 '21 03:09 khairuzzaman