objective c - SQLite insert statement does not insert the new data -


sqlite insert statement not insert new data

i using code

- (void) addn: (number *) {     const char *sql = "insert table (valuen) values(?)";     sqlite3_stmt *addstmt = nil;     nsarray *paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes);         nsstring * docsdir = [paths objectatindex:0];         nsstring * thepath = [docsdir stringbyappendingpathcomponent: @"thedb.sqlite"];         sqlite3_open([thepath utf8string], &database);         sqlite3_prepare_v2(database, sql, -1, &addstmt, null);         sqlite3_bind_int(addstmt, 1, then.thenumber);         sqlite3_step(addstmt);         sqlite3_finalize(addstmt);         sqlite3_close(database);     } 

and method insert record is

- (ibaction) saven: (id) sender {     numbers *thenumbers = [[numbers alloc] init];     number *thenumber = [[number alloc] init];     thenumber.thenumber = newn;     [thenumbers addn:thenumber];     [thenumbers release];     [thenumber release]; } 

the code executed no record inserted in db. can please point me mistake - cause there mistake :)

you're not checking return values of of sqlite3 calls. there's chance 1 of them failing.


Comments