i am trying to insert into sqlite database using objective c, the following is my code:
-(void)insertCustomer:(CustomerDetails *)cd{
CustomerDetails *cDetails=[[CustomerDetails alloc] initWithIdNumber:cd.idNumber name:cd.name surname:cd.surname];
NSString *name= cDetails.name;
NSString *surname=cDetails.surname;
NSString *idNumber=cDetails.idNumber;
NSString *insertQuery=[NSString stringWithFormat:@"INSERT INTO CUSTOMER_DETAILS(Name,Surname,ID_Number) VALUES(?,?,?);"];
sqlite3_stmt *insertStatement;
sqlite3_prepare_v2(database, [insertQuery UTF8String], 1, &insertStatement, NULL);
sqlite3_bind_text(insertStatement, 1,[name UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(insertStatement, 2,[surname UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(insertStatement, 3,[idNumber UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_step(insertStatement);
sqlite3_finalize(insertStatement);
sqlite3_close(database);
}
this is not inserting anything, also when i debug insertStatement seems to be null i am new to objective c so would appreciate any help :)
Thanks