我想从我的iPhone应用程序中删除表中的所有行.我正在使用以下代码,但它没有删除数据:
+(void)emptyData:(NSString*)dbPath{
NSString *query = @"delete from survey_question_responses";
const char *sqlStatement = [query UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSLog(@"result is here");
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
}
Run Code Online (Sandbox Code Playgroud)
NSString *query1 = [NSString stringWithFormat:@"DELETE from TableName"];
[[DBManager sharedDatabase]executeQuery:query1];
Run Code Online (Sandbox Code Playgroud)
哪里
-(void)executeQuery:(NSString*)_query
{
const char *sql = [_query cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *statement = nil;
if(sqlite3_prepare_v2(dataBaseConnection,sql, -1, &statement, NULL)!= SQLITE_OK)
{
NSAssert1(0,@"error preparing statement",sqlite3_errmsg(dataBaseConnection));
}
else
{
sqlite3_step(statement);
}
sqlite3_finalize(statement);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5194 次 |
| 最近记录: |