我有一个直截了当的问题。我想知道如何使用我的" storeID"语句:
int storeID = sqlite_column_int(statement, 0)
在我的SQLite查询中:...." StoreID =%d"。
我需要能够根据SQLite ID#选择表格单元格行。我尝试了下面的方法,但它没有识别语句中的storeID(可能是因为编译器读到了上下。
- (void)retrieveData;
{
{
NSString *query = [NSString stringWithFormat:@"SELECT StoreID, StoreName, StoreAddr, StoreHost, StorePort, StoreUser, StorePass, StoreDB FROM storelist WHERE StoreID=%d", storeID];
sqlite3_stmt* statement;
int result = sqlite3_prepare_v2(companyDB, [query UTF8String], -1, &statement, nil);
if (SQLITE_OK == result) {
while (sqlite3_step(statement)==SQLITE_ROW) {
int storeID = sqlite3_column_int(statement, 0);
NSString *name = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 1)];
NSString *address = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 2)];
NSString *host = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 3)];
NSString *port = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 4)];
NSString *user = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 5)];
NSString *pass = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 6)];
NSString *db = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 7)];
NSLog(@"StoreID= %i\tStoreName= %@\tStoreAddress= %@\tStoreHost= %@\tStorePort= %@\tStoreUser= %@\tStorePass= %@",storeID,name,address,host,port, user, pass);
Company *company = [[Company alloc]init];
[company setStoreID:storeID];
[company setName:name];
[company setAddress:address];
[company setHost:host];
[company setPort:port];
[company setUser:user];
[company setPass:pass];