03-22-2010, 01:33 AM
#1 (permalink )
Registered Member
Join Date: Mar 2010
Posts: 4
sqlite3 update text in uitextview
had the sqlite statement ready for update..but i am confuse about getting text from uitextview and updating it..and i waned to update it using a uibutton..how do i carry on after creating the sql statement???kinda lost..any new solution is appreciated..
Code:
- (void) saveAllData {
if(isDirty) {
if(updateStmt == nil) {
const char *sql = "update Snap Set snapTitle = ?, snapDesc = ?, Where snapID = ?";
if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_text(updateStmt, 1, [snapTitle UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 2, [snapDescription UTF8String], -2, SQLITE_TRANSIENT);
sqlite3_bind_int(updateStmt, 3, snapID);
if(SQLITE_DONE != sqlite3_step(updateStmt))
NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));
sqlite3_reset(updateStmt);
isDirty = NO;
}
//Reclaim all memory here.
[snapTitle release];
snapTitle = nil;
[snapDescription release];
snapDescription = nil;
//isDetailViewHydrated = NO;
}
03-22-2010, 02:09 AM
#2 (permalink )
iPhone app Developer
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
Where have u assigned the text from textview. Is snapTitle and snapDesc textviews?
If so, then you have to use "snapTitle.text" instead of "snapTitle".
03-22-2010, 02:52 AM
#3 (permalink )
Registered Member
Join Date: Mar 2010
Posts: 4
Quote:
Originally Posted by
brian
Where have u assigned the text from textview. Is snapTitle and snapDesc textviews?
If so, then you have to use "snapTitle.text" instead of "snapTitle".
erm..snapDesc..so how do i go about doing it?
by writing
Code:
- (IBAction) save_Clicked:(id)sender {
snap2playObj.snapDescription = self.viewDesc.text;
//dismiss controller
[self.navigationController dismissModalViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
}
i can "update" the text in textview but it aint storing anything into the database..because the method saveAllData wasnt being called at all..how do i call the method to update?argh
Last edited by yohliying; 03-22-2010 at 03:45 AM .
03-22-2010, 10:08 PM
#4 (permalink )
Registered Member
Join Date: Mar 2010
Posts: 4
anyone help?
03-23-2010, 12:02 AM
#5 (permalink )
iPhone app Developer
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
Quote:
i can "update" the text in textview but it aint storing anything into the database..because the method saveAllData wasnt being called at all..how do i call the method to update?argh
YOu have to call the method, where it has to be called.
if the method is in same class, you can call it by
Code:
[self saveAllData];
03-23-2010, 09:46 PM
#6 (permalink )
Registered Member
Join Date: Mar 2010
Posts: 4
if the method is in another file?
03-27-2010, 08:28 AM
#7 (permalink )
iPhone app Developer
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
Quote:
Originally Posted by
yohliying
if the method is in another file?
You should call the function by creating an instance of the class which holds the function.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 351
11 members and 340 guests
akacaj , c2matrix , cgokey , esoteric , givensur , HemiMG , Mirotion22 , mjnafjke , Pudding , SLIC , Techgirl-52
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,651
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Mirotion22