我有一个应用程序,它具有可以添加和删除患者的功能。虽然我在删除它们时遇到了问题,但效果很好。
这是sql语句:
-(void) deleteTreatmentTypeFromDatabase:(NSString *)deleteid {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"patients.sqlite"];
sqlite3 *database;
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement = "delete from records WHERE id = ?";
sqlite3_stmt *compiledStatement;
NSLog(@"%d", sqlite3_prepare(database, sqlStatement, -1, &compiledStatement, NULL));
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// LSAppDelegate *delegate = (LSAppDelegate *)[[UIApplication sharedApplication] delegate];
// Record *thisRecord = [delegate.records objectAtIndex:index.row];
sqlite3_bind_text(compiledStatement, 1, [deleteid UTF8String], -1, SQLITE_TRANSIENT);
}
if(sqlite3_step(compiledStatement) == SQLITE_DONE) {
sqlite3_finalize(compiledStatement);
}
}
sqlite3_close(database);
}
当我检查时,它说 sql 没有错误,所以我现在很好,真的被卡住了。
如果您想要更多代码,请说
提前致谢