Insert data from textfield to sqlite database

Discussion in 'iPad Apps' started by Priyankadmehta, May 7, 2012.

  1. Priyankadmehta

    Priyankadmehta
    Expand Collapse
    iPF Noob

    Joined:
    Mar 5, 2012
    Messages:
    7
    Thanks Received:
    0
    I am ipad application developer and i want to insert data from my app to sqlite database in my application i have one registration form view controller class in that there are different textfield and value in the textfield and i want to insert that textfield value in existing table of sqlite database file
    i have tried following code but it doesn't work
    My code is:
    #define sqLiteDb [[NSBundle mainBundle] pathForResource:mad:"eureka_latest1" ofType:mad:"sql"]
    if (sqlite3_open([sqLiteDb UTF8String], &_database) != SQLITE_OK) {
    NSLog(@"Failed to open database!");
    }
    sqlite3_stmt *insertStatement;
    NSString *query1 = [NSString stringWithFormat:mad:"INSERT INTO student (Fname, Mname) VALUES (\"%@\", \"%@\")",textfname.text,textmname.text];
    char *error;
    if ( sqlite3_exec(_database, [query1 UTF8String], NULL, NULL, &error) == SQLITE_OK)
    {

    NSLog(@"Data inserted.");
    sqlite3_bind_text(insertStatement, 1, [textfname.text UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(insertStatement, 2, [textmname.text UTF8String], -1, SQLITE_TRANSIENT);
    }
    else
    {
    NSLog(@"Error: %s", error);
    }
    sqlite3_finalize(insertStatement);
    sqlite3_close(_database);
    }
     
  2. aoporto

    aoporto
    Expand Collapse
    iPF Noob

    Joined:
    Nov 22, 2011
    Messages:
    6
    Thanks Received:
    0

Share This Page



Search tags for this page
flash sqlite result textfield
,
flex sqlite db query to textfield
,

how to insert data in sqlite database in iphone

,
how to store values in database using textfield in ios
,
how+to+insert+data+in+sqlite+database+in iphone
,
html code to store text field values to sqlite3 database
,
saving form data to database sqlite
,
xcode sqlite insert utf8 nsstring crash
,
xcode sqlite3 how to insert nsstring
,
xcode textfield save value