无法获取数据..从SQLite数据库获取数据;
- (void)getAmountFromDB
{
expensesArray = [[NSMutableArray alloc]init];
NSString *destinationPath = [self getDestinationPath];
const char *dbpath = [destinationPath UTF8String];
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSLog(@"month String is = %@",monthString);
NSString *querySQL = [NSString stringWithFormat: @"SELECT breakFastAmt,lunchAmt,dinnerAmt,dailyTravelAmt,outStationTravelAmt FROM TABLE_For_Expenses WHERE month=\"%@\"",monthString];
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
while (sqlite3_step(statement) == SQLITE_ROW)
{
NSLog(@"hi");
}
流动以下条件未进入。
if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
但是它的工作代码如下:
- (void) getDataFromDB
{
expensesArray = [[NSMutableArray alloc]init];
NSString *destinationPath = [self getDestinationPath];
const char *dbpath = [destinationPath UTF8String];
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM TABLE_For_Expenses"];
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
while (sqlite3_step(statement) == SQLITE_ROW)
{
NSLog (@"hi");
}
}
}
}
你为什么不使用CoreData呢? – 2012-02-14 06:54:16
与mogenerator ...? – SEG 2012-02-14 09:03:49
虽然FMDB是一个很酷的选项.. – utsabiem 2013-05-15 13:19:02