编辑:-这就是我的工具:-
- (void) Delete_LoginData {
sqlite3 *database;
if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK)
{
const char *sql = "DELETE FROM Login";
sqlite3_stmt *statement;
if(sqlite3_prepare_v2(database, sql,-1, &statement, NULL) == SQLITE_OK)
{
sqlite3_reset(statement);
}
}
}
我想一键删除数据库中的所有行。我实现了以下方法:-
- (void) Delete_LoginData {
sqlite3 *database;
if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK) {
const char *sql = "DELETE * FROM Login";
sqlite3_stmt *statement;
statement = [self PrepareStatement:sql];
// int a1 = sqlite3_bind_int(statement, 1, 1);
sqlite3_step(statement);
sqlite3_reset(statement);
}
}
-(sqlite3_stmt*) PrepareStatement:(const char *)sql{
// Setup the database object
sqlite3 *database;
// Init the animals Array
// Open the database from the users filessytem
if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = sql;
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement,-1, &compiledStatement, NULL) == SQLITE_OK) {
//NSLog(@"COMPILED STATEMENT: %@",compiledStatement);
return compiledStatement;
}
}
return nil;
}
但它不起作用。我得到这个语句的 0X0 = [self PrepareStatement:sql]; 在 delete_logindata 方法中。
如何解决这个问题。有什么解决方案吗?