Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

update data in database iphone
#1

-(IBAction)update
{

// NSString *dbpath=[self getdbpath];
NSString *dbpath=[self getdbpath];



if( sqlite3_open([dbpath UTF8String], &database) == SQLITE_OK )
{


if(updateStmnt == nil) {
const char *sql = "update Details Set name =?, adress = ?
Where rollno = ?";
if(sqlite3_prepare_v2(database, sql, -1, &updateStmnt,
NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating update statement.
'%s'", sqlite3_errmsg(database));
}

sqlite3_bind_text(updateStmnt, 1, [txt1.text UTF8String], -1,
SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmnt, 2, [txt2.text UTF8String], -1,
SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmnt, 3, [txt3.text UTF8String], -1,
SQLITE_TRANSIENT);

if(SQLITE_DONE != sqlite3_step(updateStmnt))
NSAssert1(0, @"Error while updating. '%s'",
sqlite3_errmsg(database));

sqlite3_reset(updateStmnt);
}

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)