我想在sqlite3中创建/更新文本列.当我在创建/更新后检索行时,文本为"?".但是,整数值已正确保留.
我的文字陈述如下:
const char *sql = "INSERT INTO todo(title, description, priority, status, created, expires, posx, posy, updated)"
" VALUES('?', '?', '?', '?', '?', '?', '?', '?', '?');";
if (sqlite3_prepare_v2(database, sql, -1, &insert_statment, NULL) != SQLITE_OK)
...
sqlite3_bind_text(update_statment, 5, [[dt stringFromDate:self.updated] UTF8String], -1, SQLITE_TRANSIENT);
Run Code Online (Sandbox Code Playgroud)
我已经尝试过SQLITE_TRANSIENT以及SQLITE_STATIC.两种情况似乎都产生相同的结果('?').我还验证了文本值在传递到适当的sql语句时是有效的.
有任何想法吗?
我尝试只将两个整数变量插入到我的sqlite数据库中.我创建了一个名为ups.sqlite的数据库,它有一个表(upssTable),表有两列.但是,当我打开/用户/ DS /库/应用程序支持/ iPhone模拟器/ 5.0 /应用/ FCB4B455-4B7F-4C47-81B6-AC4121874596/SqliteDeneme.app/ups.sqlite存在ups.sqlite没有数据.我的代码在这里:
- (IBAction)buttonClick:(id)sender {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [self getDBPath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(!success) {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ups.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
NSLog(@"database path %@",dbPath);
if(!(sqlite3_open([dbPath UTF8String], &cruddb) == SQLITE_OK))
{
NSLog(@"An error has occured.");
}
if(sqlite3_open([dbPath UTF8String], &cruddb) ==SQLITE_OK){
NSString * str1 =@"1";
NSString …
Run Code Online (Sandbox Code Playgroud)