VinceCarter wrote:
> i am new to android, and now i am developing one chat application.
> i have difficulties to take results from the database.
> When i execute the select query i always receive the following error:
> 
> "An error has occurred in lmu.de.exercise3. no such table: chat, while
> compiling: SELECT COUNT(*) FROM (SELECT * FROM chat where date =
> '2008-04-11')"

<snip>

>     public static final String DBASE = "chat.db";
>     public static final String TABLE = "history";
> 
>       public SQLiteDatabase db = openDB();
>       private String createTable = "CREATE TABLE " + TABLE + " (_id INTEGER
> PRIMARY KEY autoincrement, message TEXT, date TEXT, time TEXT); ";
>       private String insert, select, date, time;

Your createTable statement will create a table named 'history', since 
'history' is the value of TABLE. Other than in your error message, I 
don't see where you have a table named 'chat'.

You might want to use adb pull (or an IDE equivalent) to retrieve the 
SQLite database out of your emulator, then open it up in a SQLite client 
(e.g., SQLite Manager plugin for Firefox), to see what you really have 
in the database.

Your initialization code also assumes that, if the database exists, the 
table must exist. If you have been changing the name of your table, that 
assumption might not be correct. You can execute a query like this to 
see if your table exists:

SELECT name FROM sqlite_master WHERE type='table' AND name='...'

(where ... is the name of the table)

If the resulting Cursor has zero rows, there is no table under the name 
you specified, and you'll need to create it.

You might also need to use adb shell to delete the existing database, if 
things are really messed up and you want to start with a clean slate.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
The Busy Coder's Guide to Android Development -- coming in June 2008!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to