从tablename删除xcode sqlite不起作用

时间:2012-09-13 18:06:46

标签: objective-c xcode sqlite

我试图从表中删除数据,代码看起来没问题,当我进行调试时,表格数据似乎已被删除,但不是,请参阅下文:

这是调用方法的代码:

NSString *queryclean;
queryclean = @"DELETE FROM sharewithme_tSocialNetworks";
[self executeSentenceSetting:queryclean sentenceIsSelect:NO];

这是方法:

    -(void)executeSentenceSetting:(NSString *)sentence sentenceIsSelect:(BOOL )isSelect{
// vars for the query
static sqlite3 *db;     
sqlite3_stmt *resultado; 
const char* siguiente;  

// look for the db file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"swm.sqlite"];
NSLog(@"consulta: %@",sentence);
// open db
if (sqlite3_open([path UTF8String], &db ) == SQLITE_OK) {       

    if (isSelect){              

        // exec query
        if ( sqlite3_prepare(db,[sentence UTF8String],[sentence length],&resultado,&siguiente) == SQLITE_OK ){

            // Recorre el resultado
            while (sqlite3_step(resultado)==SQLITE_ROW){        
                responsesetting = [NSString stringWithUTF8String: (char *)sqlite3_column_text(resultado, 1)];
                NSLog(@"Resp %@",responsesetting);
            }
        }
    }
    else {
        // exec query
        if ( sqlite3_prepare_v2(db,[sentence UTF8String],[sentence length],&resultado,&siguiente) == SQLITE_OK ){
            sqlite3_step(resultado);                
            sqlite3_finalize(resultado);
        }           
    }
} 
// close db
sqlite3_close(db); }

0 个答案:

没有答案