Piet
Piet

Reputation: 415

SQLiteException: no such table:

here is my code for selecting something from the table SqliteTmp:

 Cursor c=null;
                    DataBaseHelper myDbHelper = new DataBaseHelper(StaffActivity.this);
                    try {
                        myDbHelper.createDataBase();
                    } catch (IOException ioe) {
                        throw new Error("Unable to create database");
                    }
                    try {
                        myDbHelper.openDataBase();

                    }catch(SQLException sqle){

                        throw sqle;
                    }
                    Toast.makeText(StaffActivity.this, "Success", Toast.LENGTH_SHORT).show();
                    c=myDbHelper.query("SqliteTmp", null, null, null, null,null, null);
                    if(c.moveToFirst())
                    {
                        do {

                            Toast.makeText(StaffActivity.this,
                                    "_id: " + c.getString(0) + "\n",  
                                    Toast.LENGTH_LONG).show();
                        } while (c.moveToNext());
                    }
                }

Logcat says this:

android.database.sqlite.SQLiteException: no such table: SqliteTmp (code 1): , while compiling: SELECT * FROM SqliteTmp

but the SqlTmp.db shows that:

CREATE TABLE `SqliteTmp` (
    `_id`   int(11) NOT NULL,
    `ean`   varchar(12) NOT NULL,
    `bezeichnung`   varchar(100) NOT NULL,
    `art`   varchar(1),
    `stammkost` varchar(4),
    `marker`    varchar(1),
    PRIMARY KEY(_id)
);

Why the SqliteTmp table isn't found? Its really in it.

Upvotes: 0

Views: 1152

Answers (2)

Ekant Sharma
Ekant Sharma

Reputation: 57

I think i have got the same problem. Please make sure you have diffrent database name for each table. This will surly solve your problem.

Upvotes: 1

Joel Fazio
Joel Fazio

Reputation: 172

Make sure that your database path and file name are correct. Depending on your code, it is probably creating a blank database instead of opening yours.

Upvotes: 0

Related Questions