我有一个名为的 db 表FINALORDER
,其中填充了一些数据,然后显示在 tableview 中。
我在alertview
里面插入了一个didSelectRowAtIndexPath
..
alert=[[UIAlertView alloc]initWithTitle:@"Cancel Order" message:@"Do you want to cancel the order" delegate:self cancelButtonTitle:@"dismiss" otherButtonTitles:@"Ok",nil];
[alert show];
[alert release];
委托方法如下:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
const char *dbpath = [databasePath UTF8String];
sqlite3_stmt *statement;
if(buttonIndex==1)
{
NSString *deleteSQL = @"DELETE FROM FINALORDER WHERE itemname=?";
if (sqlite3_prepare_v2(database, [deleteSQL UTF8String], -1, &statement, NULL) != SQLITE_OK)
NSLog(@"%s error preparing %s", __FUNCTION__, sqlite3_errmsg(database));
if (sqlite3_bind_text(statement, 1, [itemname UTF8String], -1, NULL) != SQLITE_OK)
NSLog(@"%s error binding %s", __FUNCTION__, sqlite3_errmsg(database));
if (sqlite3_step(statement) != SQLITE_DONE)
NSLog(@"%s error executing %s", __FUNCTION__, sqlite3_errmsg(database));
if (sqlite3_finalize(statement) != SQLITE_OK)
NSLog(@"%s error finalizing %s", __FUNCTION__, sqlite3_errmsg(database));
}
}
我应该如何获得可以代替问号的项目名称?请注意,我的数据库包含以下字段itemname,quantity,totalcost