简体   繁体   中英

Warning: passing Argument 1 of “sqlite3_bind_text” from incompatible pointer type" What should I do for this?

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);

} 

您必须在第一个参数中传递已编译的语句( compiledStatement ),而不是文本sql语句( sqlStatement

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM