在我的应用程序在一个循环中打开数据库大量的时间,然后再次打开我的数据库,它不会执行if (sqlite3_open([[self getDBPath] UTF8String], &database) == SQLITE_OK)
这种说法使我的应用程序不工作....数据库应用程序无法正常工作
-(NSString *)getDBPath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"BasicGreetings.sqlite"];
}
-(void) fillimage:(NSInteger)imgno
{
testAppDelegate *appDelg = (testAppDelegate *)[[UIApplication sharedApplication]delegate];
sqlite3 *database= nil;
if (sqlite3_open([[self getDBPath] UTF8String], &database) == SQLITE_OK)
{
const char *sql = "select setflag from Tblsetflag where imgNo = ?";
sqlite3_stmt *selectStmt = nil;
if (sqlite3_prepare_v2(database, sql, -1, &selectStmt, NULL) == SQLITE_OK)
{
sqlite3_bind_int(selectStmt, 1,imgno);
while (sqlite3_step(selectStmt) == SQLITE_ROW)
{
appDelg.a = sqlite3_column_int(selectStmt, 0);
NSLog(@"%d",appDelg.a);
}
}
}
sqlite3_close(database);
}
我把上面的getDBpath方法....和.sqlite文件在应用程序文件夹中可用... – 2011-03-24 12:35:47
Thanx给我一个建议.... – 2011-03-25 07:17:47