selectStmt = nil;
NSString strParam1 = @"%SF1%";
NSString strParam2 = @"%SF2%";
const char *selectSql;
//prepare select statement
if(sqlite3_prepare_v2(database, sqlStatement, -1, &selectStmt, NULL) == SQLITE_OK)
{
//Bind your parameter
sqlite3_bind_text(selectStmt, 1, [strParam1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(selectStmt, 2, [strParam2 UTF8String], -1, SQLITE_TRANSIENT);
while(sqlite3_step(selectStmt) == SQLITE_ROW)
{
//Read your values from database
NSString *f1Value = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStmt, 0)];
NSString *f2Value = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStmt, 1)];
}
}
感謝,我通過連接nsmutablestrings解決了,然後我做: 的char *更改爲MyQuery = UTF8字符串mynsmutablestring] 使用sqlite3_bind的是最好的方法? – longy
很高興幫助你。 –