iOS dev
iOS dev

Reputation: 2284

How to insert date & int in to sqlite databse

Im using SQlite in my iPhone app. to insert date value i used code like this:

    NSDate *time;
    [dict setObject:time forKey:@"time"];

    if(sqlite3_bind_text(insertStmt, 1, [time NSDate], -1, SQLITE_TRANSIENT) != SQLITE_OK) 
   {

        return NO;
    }


    int type;       
     NSNumber *type = [NSNumber numberWithInt:type];
            [dict setValue:type forKey:@"type"];
    if(sqlite3_bind_text(insertStmt, 2, [type int], -1, SQLITE_TRANSIENT) != SQLITE_OK) 
     {

        return NO;
    }

it shows an warning: incomplete pointer type passing 'id' to perameter of type const char

what to do ? thanks in advance..

Upvotes: 0

Views: 1530

Answers (2)

Gopesh Gupta
Gopesh Gupta

Reputation: 707

No need to convert the int value into NSNumber..

sqlite3_bind_int(insertStmt,2,type);

Upvotes: 2

Tendulkar
Tendulkar

Reputation: 5540

change like this for inserting int value in database

 sqlite3_bind_int(updStmt, 4, [type int]);

Upvotes: 1

Related Questions