> Hello All,
>
> I am having trouble reading the second table from my database because it
> returns nothing even if there is data inside it.
How do you know it has data inside it ? A common mistake is to try to write to
databases in the read only part of an application's sandbox on the iphone.
Where in the sandbox is the database ?
> - (NSMutableArray*) getProvinces
> {
> NSMutableArray * data = [[NSMutableArray alloc] init];
> const char * sql = "SELECT * FROM Provinces";
> sqlite3_stmt * statement;
>
> //prepare the select statement
> int returnValue = sqlite3_prepare_v2(mDatabase, sql, -1, &statement, NULL);
>
> DebugLog("return value = %d\n",returnValue);
>
> if (returnValue == SQLITE_OK)
> {
> //sqlite3_bind_int(statement, 1, regionID);
> //loop all the rows returned by the query
> while (sqlite3_step(statement) == SQLITE_ROW)
> {
You don't check the return codes here properly. sqlite3_prepare_v2() can
return SQLITE_BUSY, or SQLITE_SCHEMA, or SQLITE_MISUSE. More importantly, you
don't check if sqlite3_step() returns SQLITE_DONE which would indicate that you
have 0 rows in this table.
- Ben
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]