繁体   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