ios5 - Not able to update sqlite3 table iOS 5 -


i working on core location framework, trying calculate distance between coordinates , updating distance onto database(sqlite3.0). reason redundant data getting updated. im not sure if code correct updating. need serious guys. thank you.

here goes code:

    if(sqlite3_open([writabledbpath utf8string],&controller)==sqlite_ok){     nsstring *str=[nsstring stringwithformat:@"select * coordinate_table"];     sqlite3_prepare_v2(controller, [str utf8string], -1, &statement, null);     int i=0;      while(sqlite3_step(statement)==sqlite_row){         newlat=sqlite3_column_double(statement, 0);         newlongi=sqlite3_column_double(statement, 1);          cllocation *newloc=[[cllocation alloc]initwithlatitude:newlat longitude:newlongi];          cllocationdistance dis=[currloc distancefromlocation:newloc];          nsstring *dist=[nsstring stringwithformat:@"%f",dis];              [marr insertobject:dist atindex:i];          nsstring *sql=[nsstring stringwithformat:@"update coordinate_table set distance=%f latitude=%f , longitude=%f",dis,newlat,newlongi];         nslog(@"%@",sql);         int res=sqlite3_exec(controller, [sql utf8string], null, null, null);          nslog(@"%d",res);         i++;      }     nslog(@"distance array %@",marr); } sqlite3_finalize(statement); sqlite3_close(controller); [tview reloaddata];  } 

i recommend use fmdb lib working sqlite. it's powerful sqlite wrapper. it's simple using! question:

how fmdb makes sqlite more simpler ios?

hope helps you)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -