我在一个表格中存储了一个包含多个不同类型列的值集合,并且当我在iPhone模拟器上运行该应用程序时插入和选择工作正常。但是,在真实设备上运行并选择数据时,它看起来似乎无法获取表格的某些文本列(其余列似乎被正确检索)。在哪里我应该显示一个字符串对话框,我不是,我得到一个空的对话框,而与字符串对话框正确地显示在模拟器上。SQLite3的选择在模拟器上,但它不在设备上
这是插入的代码片段:
if(sqlite3_prepare_v2(database, sqlStatement,
-1, &compiledStatement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(compiledStatement, 1, userData.ID);
sqlite3_bind_double(compiledStatement, 2, userData.Location.Lat);
sqlite3_bind_double(compiledStatement, 3, userData.Location.Lon);
sqlite3_bind_text(compiledStatement, 4, [userData.Name UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 5, [userData.Surname UTF8String], -1, SQLITE_TRANSIENT);
}
if(sqlite3_step(compiledStatement) == SQLITE_DONE) {
sqlite3_finalize(compiledStatement);
}
else {
NSLog(@"%d",sqlite3_step(compiledStatement));
}
}
sqlite3_close(database);
这是选择:
if (sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
UserData *userData = [[UserData alloc] init];
userData.ID = sqlite3_column_int(compiledStatement, 0);
char *name = sqlite3_column_text(compiledStatement, 1);
if (name == nil)
userData.Name = @"";
else
userData.Name = [NSString stringWithUTF8String: name];
[list addObject:userData];
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
我完全不知道为什么数据库的数据管理在模拟器表现好(我有SQLite管理器插件和数据被正确存储和检索),但它不在真正的iPhone中。我如何检查设备上发生了什么?有人经历过类似的事吗?
谢谢!
显示你的SQL请求 – Oleg
那的代码片断第二有两个开放的大括号“{”和三贴近“}”,所以我不知道这是怎么回事连接。无论如何,这里是我的代码片段,工作正常。 char * localityChars =(char *)sqlite3_column_text(statement,1); if(localityChars == NULL)返回FALSE; ,至于绑定文本,你做它不同于我的应用程序这样做:sqlite3_bind_text(stmt,4,[myString UTF8String],-1,NULL); – Chris