0
我有一點麻煩聲明:sqlite3_prepare_v2問題
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
在下面的代碼
,代碼此時跳出IF的。任何任何想法?
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = "select route_name from Route";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
// Read the data from the result row
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
// Add the animal object to the animals Array
//[list addObject:animal];
[list addObject:aName];
//[animal release];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
我已更改代碼以輸出錯誤消息,詳細信息如下: 錯誤:無法從數據庫中選擇消息'沒有此表格:路由'的詳細信息。 肯定有一張名爲'路線'的表。 – Stephen 2010-07-20 09:37:44
問題解決了,當我通過Firefox插件SLQite Manage查看數據庫時,表名實際上稱爲ZROUTE。 – Stephen 2010-07-20 09:40:30