Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert multiple row of data to sqlite database by iphone programming
    primarykey
    data
    text
    <p>I am new to iphone development.I want to insert multiple values into my sqlite3 database and display the content in the tableview.I am able to insert single row of data in to my database and retrieve it and display the data but i am not able to do with inserting multiple row of data.Here is my code...</p> <pre><code>-(void)initializeTableData{ sqlite3 *db=[DatabaseTestAppDelegate getNewDBConnection]; sqlite3_stmt *statement=nil; sqlite3_stmt *statement1=nil; if (insert_MyObj_statement == nil) { const char *sql2="DELETE FROM user"; sqlite3_prepare_v2(db, sql2, -1, &amp;statement1, NULL); sqlite3_step(statement1); //const char *sql1 = "INSERT INTO user (id,name) VALUES ('0','ash'),('3','karna'),('2','kumar'),('5','siva')"; const char *sql1 = "INSERT INTO user (id,name) VALUES ('0','xxx')"; int result=sqlite3_prepare_v2(db, sql1, -1, &amp;insert_MyObj_statement, NULL); NSAssert1(result == SQLITE_OK, @"addMyObjectIntoDatabase: failed to prepare statement with err '%s'", sqlite3_errmsg(db)); } sqlite3_step(insert_MyObj_statement); const char *sql="select * from user"; if(sqlite3_prepare_v2(db, sql, -1, &amp;statement, NULL)!=SQLITE_OK) NSAssert1(0,@"error in preparing staement",sqlite3_errmsg(db)); else{ while(sqlite3_step(statement)==SQLITE_ROW) [tableData addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement,1)]]; } sqlite3_finalize(statement); } </code></pre> <p>Is there any other way to insert multiple row of data in to my table .Please help me out.Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload