NSString *query = @"INSERT INTO PatientInfo
(PatientName,PatientId,PatientMobile,PatientEmail,Patientdates,Patientdesc) VALUES(?,?,?,?,?,?)";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(_sqldatabase, [query UTF8String], -1, &statement, nil) == SQLITE_OK)
{
NSLog(@"In Insert function");
char* errmsg;
sqlite3_bind_text(statement, 1, [userModel.PatientName UTF8String] ,-1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 2, [userModel.PatientId UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 3, [userModel.MobileNo UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 4, [userModel.PEmail UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 5, [userModel.date UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 6, [userModel.description UTF8String], -1, SQLITE_TRANSIENT);
if(sqlite3_step(statement) != SQLITE_DONE )
{
sqlite3_finalize(statement);
sqlite3_exec(_sqldatabase, "COMMIT", NULL, NULL, &errmsg);
NSLog( @"addUser Error: %s", sqlite3_errmsg(_sqldatabase) );
return NO;
}
else
{
sqlite3_finalize(statement);
sqlite3_exec(_sqldatabase, "COMMIT", NULL, NULL, &errmsg);
NSLog(@"Data Inserted into Table.PatientInfo");
return YES;
}
I am using the above code for inserting values into database but it is not inserting value why?
Aucun commentaire:
Enregistrer un commentaire