Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c SQLite update语句不工作_Objective C_Sqlite - Fatal编程技术网

Objective c SQLite update语句不工作

Objective c SQLite update语句不工作,objective-c,sqlite,Objective C,Sqlite,您好,我正在使用update语句更新sqlite数据库中的记录。请帮助我我的代码有什么错误。我不明白哪里错了。我正在使用下面的代码 在sqlite3\u bind\u text语句之后调用sqlite3\u步骤失败。因此,您从未实际执行过SQL 因此,它应该看起来像: sqlite3 *database; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES

您好,我正在使用update语句更新sqlite数据库中的记录。请帮助我我的代码有什么错误。我不明白哪里错了。我正在使用下面的代码



sqlite3\u bind\u text
语句之后调用
sqlite3\u步骤
失败。因此,您从未实际执行过SQL

因此,它应该看起来像:

sqlite3 *database;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"Notes.sqlite"];
sqlite3_stmt *updateStmt = nil;
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK)
{
    const char *sql = [[NSString stringWithFormat:@"update Notess Set Name=? Where NoteId = %@",_notesId] UTF8String];

    if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
        NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database));

    if (sqlite3_bind_text(updateStmt, 1, [textVew.text  UTF8String], -1, SQLITE_TRANSIENT) != SQLITE_OK)
        NSLog(@"Error while binding value. %s", sqlite3_errmsg(database));

    if (sqlite3_step(updateStmt) != SQLITE_DONE)
        NSLog(@"Error during step. %s", sqlite3_errmsg(database));

    sqlite3_finalize(updateStmt);
    sqlite3_close(database);
}else{
    NSLog(@"Error while opening database");
}

什么不起作用?你是如何测试中间变量的值的?@Murali..那你为什么还没有接受它作为你的答案?…当有人通过投入时间帮助你解决问题时,然后学会回报他们一些东西…谢谢。。。
sqlite3 *database;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"Notes.sqlite"];
sqlite3_stmt *updateStmt = nil;
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK)
{
    const char *sql = [[NSString stringWithFormat:@"update Notess Set Name=? Where NoteId = %@",_notesId] UTF8String];

    if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
        NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database));

    if (sqlite3_bind_text(updateStmt, 1, [textVew.text  UTF8String], -1, SQLITE_TRANSIENT) != SQLITE_OK)
        NSLog(@"Error while binding value. %s", sqlite3_errmsg(database));

    if (sqlite3_step(updateStmt) != SQLITE_DONE)
        NSLog(@"Error during step. %s", sqlite3_errmsg(database));

    sqlite3_finalize(updateStmt);
    sqlite3_close(database);
}else{
    NSLog(@"Error while opening database");
}