簡體   English   中英

FMDB executeUpdate不改變數據庫

[英]FMDB executeUpdate not altering database

向表格中插入新項目非常有效,但更新無效。

我使用以下語句來更新我的數據庫。

BOOL success = [fmDB executeUpdate:@"UPDATE activities SET type = ?, author = '?', 
                time = '?', location = '?', node = '?', nodeID = ? 
                WHERE itemid = ?", [NSNumber numberWithInt:itemType], author, 
                time, location, node, [NSNumber numberWithInt:nodeID], 
                [NSNumber numberWithInt:itemID], nil];

未被包裝為NSNumber的所有內容都是NSString(它們都按預期注銷)。

命令運行時收到0錯誤(成功bool返回TRUE)

下次我讀取我的數據庫時,尚未進行更改。

有任何想法嗎?

好的,所以我讓它工作..一些如何..

 BOOL success = [fmDB executeUpdateWithFormat:@"UPDATE activites 
   SET type = %@, node = %@, time = %@, location = %@, author = %@, 
   nodeID = %@ WHERE itemid = %@", [NSNumber numberWithInt:itemType], 
   node, time, location, author, [NSNumber numberWithInt:nodeID], 
   [NSNumber numberWithInt:itemID], nil];

直到我從字符串對象周圍刪除了's'才行。

 if([db open])
 {
    NSString *queryStr ;
    queryStr = [NSString stringWithFormat:@"Update activities SET type = ?, author = '?', 
            time = '?', location = '?', node = '?', nodeID = ? 
            WHERE itemid = ? ",[NSNumber numberWithInt:itemType], author, 
            time, location, node, [NSNumber numberWithInt:nodeID], 
            [NSNumber numberWithInt:itemID]];
    [db executeUpdate:queryStr];
    NSLog(@"UPDATE\n%@",queryStr);
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM