2013-03-04 228 views
0

我正在使用iPhone 6.1模拟器,它的工作原理。但是,当我进入iPhone [iOS 6.1]时,出现错误“更新时发生错误,而不是错误”。帮帮我!!!!在模拟器6.1中工作,但不在iPhone上iOS 6.1

NSString *filePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"myDatabase.sqlite"]; 


    NSString* str2 = SeqNo1.text; 
    sqlite3 *database; 
    sqlite3_stmt *updateStmt=NULL; 
    if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) 
    { 
     NSString* sql= [NSString stringWithFormat:@"UPDATE MyTable Set MyField2 = \"%@\" WHERE MyField1 = \"%@\"", @"Y", str2]; 
     if(sqlite3_prepare(db, [sql cStringUsingEncoding:NSASCIIStringEncoding], -1, &updateStmt, NULL) != SQLITE_OK) 
      NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database)); 
    } 
    if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK)   
    { 
    int step = sqlite3_step(updateStmt); 
    if(step != SQLITE_DONE) 

     NSLog(@"Error while updating. %s", sqlite3_errmsg(database)); // THIS WHERE THE ERROR IS OCCURRING 
    sqlite3_finalize(updateStmt); 
    sqlite3_close(database); 
    } 
    else{ 
     NSLog(@"Error while Opening Databse. %s", sqlite3_errmsg(database)); 
    } 
+0

什么是SeqNo1.text设置为? – AnthonyLambert 2013-03-04 11:26:06

回答

1

MainBundle是只读。你不能修改Bundle中的文件。

您需要将数据库文件复制到文档目录,并且需要从那里读取和写入。不是来自Bundle。

+0

Midhun - 感谢您的咨询。这工作。 – 2013-03-05 06:08:02

+0

@BurtRosner:与快乐:) – 2013-03-05 06:12:09

相关问题