Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to delete row from sqlite database in iPhone from tableview
    primarykey
    data
    text
    <p>i want some help for deleting rows in database through Tableview. In my app i am using SKDatabase file for query. now when i call delete query it doesn't work. below is my code </p> <pre><code> - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { i = indexPath.row; if (editingStyle == UITableViewCellEditingStyleDelete) { [objappdel.sk deleteWhere:[NSString stringWithFormat:@"ID = %d",indexPath.row] forTable:@"Highlights_Table"]; tablstr = [arrayFinal objectAtIndex:indexPath.row]; NSLog(@" %@",tablstr); [arrayFinal removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } [table1 reloadData]; } </code></pre> <p>if i am using delete all data query then it is working, i dont know tht how to solve this. please help. </p> <p>Delete method code in SKDatabase.m</p> <pre><code>- (void)deleteWhere:(NSString *)where forTable:(NSString *)table { NSString *sql = [NSString stringWithFormat:@"DELETE FROM %@ WHERE %@", table,where]; NSLog(@" %@",sql); [self runDynamicSQL:sql forTable:table]; } - (BOOL)runDynamicSQL:(NSString *)sql forTable:(NSString *)table { int result; NSAssert1(self.dynamic == 1,[NSString stringWithString:@"Tried to use a dynamic function on a static database"],NULL); sqlite3_stmt *statement; if (statement = [self prepare:sql]) { result = sqlite3_step(statement); } sqlite3_finalize(statement); if (result) { if (self.delegate != NULL &amp;&amp; [self.delegate respondsToSelector:@selector(databaseTableWasUpdated:)]) { [delegate databaseTableWasUpdated:table]; } return YES; NSLog(@"Done"); } else { return NO; } } - (sqlite3_stmt *)prepare:(NSString *)sql { const char *utfsql = [sql UTF8String]; NSLog(@" %s",utfsql); sqlite3_stmt *statement; if (sqlite3_prepare([self dbh],utfsql,-1,&amp;statement,NULL) == SQLITE_OK) { return statement; } else { return 0; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload