English 中文(简体)
SQlite-FMDatabase query while loop not working
原标题:SQlite-FMDatabase query while loop not working

我的表格“关键词”,有两栏“pk”和“text”。 在消防局管理人员中,我可以看到,在“文字”一栏中,有两种名称为“john”和“tom”。 我的法典中没有错误或警告。 当我用模拟器操作时,我可以看到,我从来就没有进入。 这意味着FMResultSet的“器”没有从QQ.中取得任何结果。 我正在获得“成功”的信息,这意味着我的数据库已经开放,没有任何问题,数据库的名称也正确。 我的询问也正确,因为它没有显示奥索尔的任何质疑错误。 但是,我并没有获得“开始循环”的信息。 我知道,尽管 lo不工作,但我的数据库阵列也是空的。 我正在使用千年发展目标数据库。 我的法典

-(void) readWordsfromDatabase
{   
db=[FMDatabase databaseWithPath:globalDatabasePath];
globalDatabaseArray=[[NSMutableArray alloc] init];
[db setLogsErrors:TRUE ];
[db setTraceExecution:TRUE];
if (![db open])
{
    NSLog(@"Failed to open database");
    return;
}
else {
    NSLog(@"Opened successfully");
}
FMResultSet *rs= [db executeQuery:@"SELECT * FROM keywords"];
while([rs next])
{
    NSLog(@"while loop started");

    int aPK=[rs intForColumn:@"pk"];
    NSString *aText=[rs stringForColumn:@"text"];
    NSLog(@"aText is %@",aText);

    singleKeyword *sk=[[singleKeyword alloc] initWithData:aPK :aText];
    [globalDatabaseArray addObject:sk];
    [sk release];

            NSLog(@"text in array%@",[self.globalDatabaseArray  objectAtIndex:0]);  
    NSLog(@"text in array%@",[self.globalDatabaseArray  objectAtIndex:1]);
}//while closed
//NSLog(@"text in array%@",[self.globalDatabaseArray  objectAtIndex:0]);
    // NSLog(@"text in array%@",[self.globalDatabaseArray  objectAtIndex:1]);   
[db close];
}
问题回答

FMDB正在开放数据库,不管档案的道路是否存在(实际上,FMDB也设计了你可以打电话[FMDatabase数据库]。 带Path:nil],不作错误或警告。 如果你要检查一下你是否打开了正确的数据库,那么你就必须利用国家扫盲基金会,验证道路。

- (BOOL)fileExistsAtPath:(NSString *)path

最常见的错误是,贵方-manager和贵方行都提到了不同的数据库。





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签