0
我想使用NSMutableArray
在我的tableview中顯示來自我的sqlite數據庫的一些數據。FMDB的錯誤 - 未知的列名
當我使用AssetDesc
作爲我的單元格文本時,我可以在我的UITableCell
的sqlite數據庫中看到我的描述。所以我知道一切正常。
然而,當我使用ASSETNAME作爲我的手機文本我得到一個sqlite的錯誤說:
Warning: I could not find the column named 'AssetName'.
如果我改變這一行:
customer.assetName = [results stringForColumn:@"AssetName"];
這樣的:
customer.assetName = [results stringForColumn:@"AssetDesc"];
它可以工作,所以它必須是我的數據庫中的東西,但我不能指出它。
但我確定那是在我的資產表中。這對我來說很合理。下面是我的數據庫和代碼的圖片:
-(NSMutableArray *) getCustomers
{
NSMutableArray *customers = [[NSMutableArray alloc] init];
FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
FMResultSet *results = [db executeQuery:@"SELECT * FROM asset"];
while([results next])
{
Customer *customer = [[Customer alloc] init];
customer.assetId = [results intForColumn:@"AssetID"];
customer.assetName = [results stringForColumn:@"AssetName"];
customer.assetDesc = [results stringForColumn:@"AssetDesc"];
[customers addObject:customer];
}
[db close];
return customers;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomerCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Customer *customer = [self.customers objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[NSString stringWithFormat:@"%@",customer.assetName]];
[[cell detailTextLabel] setText:[NSString stringWithFormat:@"%@",customer.assetDesc]];
return
}
當你調試這個時,'[result resultDictionary]'中的鍵是什麼? –
只是一個方面說明:你不打開和關閉請求之間的數據庫,你創建一個查詢,然後關閉查詢,當你完成枚舉它 – CodaFi
2013-06-01 23:22:39.840 [3759:907]字典:( 「<客戶:0x1f5bfda0>」, 「<客戶:0x1f5bfeb0>」, 「<客戶:0x1f5bff20>」 ) –