無法獲取數據..從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