Hi All, i am pretty new in iphone development. I have created one function to insert data into database. The code compiles successfully. But when comes to statement sqlite3_bind_text(sqlStatement, 1, [s UTF8String], -1, SQLITE_TRANSIENT);
it does not do anything but hangs AND in warning it says "passing Argument 1 of "sqlite3_bind_text" from incompatible pointer type"" for all statements in Red colour
The same code i am using to fetch the data from database and its working on other viewController.
Below in the code. Its pretty straightforward. Please help guys.
-(void) SaveData: (NSString *)FirstName: (NSString *)LastName: (NSString *)State: (NSString *)Street: (NSString *)PostCode
{
databaseName = @"Zen.sqlite";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask,YES);
NSString *documentsDir=[documentPaths objectAtIndex:0];
databasePath=[documentsDir stringByAppendingPathComponent:databaseName];
sqlite3 *database;
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
const char *sqlStatement = "insert into customers (FirstName, LastName, State, Street, PostCode) values(?, ?, ?, ?, ?)";
sqlite3_stmt *compiledStatement;
sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL);
sqlite3_bind_text(sqlStatement, 1, [FirstName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(sqlStatement,2,[LastName UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_bind_text(sqlStatement,3,[State UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_bind_text(sqlStatement,4,[Street UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_bind_text(sqlStatement,5,[PostCode UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_step(sqlStatement);
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}