Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-19-2011, 02:05 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Islamabad
Posts: 47
Khurshid is on a distinguished road
Lightbulb Problem With SQLITE

hi
i have build an application that is using sqlite3. i can add and delete data from sqlite.
problem is with updating data.
i am using tableview to display account names, and when user select row from tableview, i display all detail about selected account in a detailview. here (in detail view ) user will see existing values and can change/update that value
now my problem is that updation is not taking place i can edit values but icant see updated values in sqlite DB or in table view.
any help regarding this will be appreciated

Thanks.
Khurshid is offline   Reply With Quote
Old 10-19-2011, 03:08 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2011
Location: Bucharest, Romania
Age: 22
Posts: 75
nestedloop is on a distinguished road
Default

Please post code of your Update method (the one where you update the data in the DB).
nestedloop is offline   Reply With Quote
Old 10-19-2011, 03:13 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Islamabad
Posts: 47
Khurshid is on a distinguished road
Default

Quote:
Originally Posted by nestedloop View Post
Please post code of your Update method (the one where you update the data in the DB).
- (void) updateData {

if(updateStmt == nil) {

const char *sql = "update tbl Set f1 = ?,f2 = ?,f3 = ?,f4 = ?,f5= ?,f6 = ? Where ID = ?";
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, [name UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 2, [a UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 3, [b UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 4, [c UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 5, [d UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStmt, 6, [he UTF8String], -1, SQLITE_TRANSIENT);

sqlite3_bind_int(updateStmt, 7, uniqueId);

if(SQLITE_DONE != sqlite3_step(updateStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
//SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
//uniqueId = sqlite3_last_insert_rowid(database);

//Reset the add statement.
sqlite3_reset(updateStmt);
Khurshid is offline   Reply With Quote
Old 10-19-2011, 03:18 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Location: Bucharest, Romania
Age: 22
Posts: 75
nestedloop is on a distinguished road
Default

This seems alright... Have you checked if the variables (name, a, b, c, d, he, uniqueId) have the correct values when running the update function? I mean, after you modify the data in the UI, do they contain the new values, that are to be written in DB?

Cheers.
nestedloop is offline   Reply With Quote
Old 10-19-2011, 03:29 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Islamabad
Posts: 47
Khurshid is on a distinguished road
Default

Quote:
Originally Posted by nestedloop View Post
This seems alright... Have you checked if the variables (name, a, b, c, d, he, uniqueId) have the correct values when running the update function? I mean, after you modify the data in the UI, do they contain the new values, that are to be written in DB?

Cheers.
thanks for your time i solved issue.
Khurshid is offline   Reply With Quote
Old 10-19-2011, 03:31 AM   #6 (permalink)
Registered Member
 
Join Date: Feb 2011
Location: Bucharest, Romania
Age: 22
Posts: 75
nestedloop is on a distinguished road
Default

What was the problem?
nestedloop is offline   Reply With Quote
Old 10-19-2011, 03:56 AM   #7 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Islamabad
Posts: 47
Khurshid is on a distinguished road
Default

Quote:
Originally Posted by nestedloop View Post
What was the problem?
problem was with id (pk)
now i have set the value of PK to value of pk of data that is being edited
Khurshid is offline   Reply With Quote
Reply

Bookmarks

Tags
database, database updation, query problem, sqlite, upadtating sqlite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 407
15 members and 392 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, j.b.rajesh@gmail.com, LunarMoon, morterbaher, n00b, QuantumDoja, sacha1996, Sami Gh, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0