Hi all,
I am currently experimenting with SQLite on the iOS, but something seems wrong, I can't get to my table, even though I know it exists. The .sqlite file was created using SQLite manager for firefox, then imported into the XCode project as a resource (is this the appropiate way to do this?). Then I inserted one record into it using the "sqlite3" Terminal command. However, when I try to access that record through the Sqlite APIs, I get a "no such table" error!
Here's the code:
Execution always takes goes to the else and assigns the string "no such table: Descuento" to errMsg. Does anyone have an idea what I might be doing wrong?
I am currently experimenting with SQLite on the iOS, but something seems wrong, I can't get to my table, even though I know it exists. The .sqlite file was created using SQLite manager for firefox, then imported into the XCode project as a resource (is this the appropiate way to do this?). Then I inserted one record into it using the "sqlite3" Terminal command. However, when I try to access that record through the Sqlite APIs, I get a "no such table" error!
Here's the code:
Code:
-(IBAction) howManyDiscounts
{
sqlite3 *con;
sqlite3_stmt *stmt;
if (sqlite3_open("Descuentos.sqlite",&con) == SQLITE_OK)
{
const char *q = "select * from Descuento;";
if( sqlite3_prepare_v2(con, q, -1, &stmt, NULL) == SQLITE_OK)
{
sqlite3_step(stmt);
lblCount.text = [NSString stringWithFormat:@"%s",sqlite3_column_text(stmt,1)];
}
else
{
const char *err = sqlite3_errmsg(con);
NSString *errMsg = [NSString stringWithFormat:@"%s",err];
NSLog(errMsg);
}
}
sqlite3_finalize(stmt);
sqlite3_close(con);
}
Execution always takes goes to the else and assigns the string "no such table: Descuento" to errMsg. Does anyone have an idea what I might be doing wrong?
Last edited: