簡體   English   中英

如何在iOS sqlite中選擇Row並在應用程序中檢索它

[英]how to select Row in ios sqlite and retrive it in application

我希望我的數據庫應該正確響應

我正在使用此查詢來調用我的數據庫

sqlStatement = [[NSString stringWithFormat:@"SELECT _id,Operator,Circle FROM mobile_codes WHERE _id LIKE "%@"",MobileNum.text]UTF8String];

和,

sqlStatement = [[NSString stringWithFormat:@"SELECT _id,Operator,Circle FROM mobile_codes WHERE _id = "%@"",MobileNum.text]UTF8String];

我使用了這兩種方法,但仍然沒有得到任何結果

這是用於連接sqlite數據庫和簡單選擇查詢的代碼Employee是用於訪問其數據的模型類

define @property sqlite3 *ContactDB; in header file
sqlite3_open([_databasePath UTF8String], &_ContactDB);
NSString *stmt=@"select * from employee";
sqlite3_stmt *statement;
sqlite3_prepare_v2(self.ContactDB, [stmt UTF8String], -1,&statement, NULL);


while(sqlite3_step(statement)==SQLITE_ROW)
{
    self.employee=[[Employee alloc]init];
    self.employee.empId=(NSInteger *)sqlite3_column_int(statement,0);
    self.employee.empName=[NSString stringWithFormat:@"%s",sqlite3_column_text(statement,1)];
    self.employee.empAddress= [NSString stringWithFormat:@"%s",sqlite3_column_text(statement,2)];
    self.employee.empCity= [NSString stringWithFormat:@"%s",sqlite3_column_text(statement,3)];
    self.employee.empSalary= [NSString stringWithFormat:@"%i",sqlite3_column_int(statement,4)];
    self.employee.departmentId=[NSString stringWithFormat:@"%i", sqlite3_column_int(statement,5)];
    [self.EmployeesDisplayArray addObject:self.employee];
}
sqlite3_finalize(statement);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM