0

every one. I'm trying to use my custom database. So I written following. But If when i ran this, i found it return nil.

Why?

I didn't find why this is.

Please help me.

NSString *name ;
NSString * content ;
FMResultSet *rs = [db executeQueryWithFormat:@"SELECT name, content FROM projects WHERE id = %d", projectID];

Here projectID is a given parameter. And i had a breakpoint just next line.

//if ([rs next]) {
    name = [rs stringForColumnIndex:0];
    content = [rs stringForColumnIndex:1];
    [rs close];
    return [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", content, @"content", nil];
//}
[rs close];
return nil;

At the resutl, the name and content was nil. What happened?

Before that, db is opened correctly, and i updated it. I saw this by log and commandline of sqlite3 on terminal.

Please help me!

4

1 に答える 1

0

ドキュメントを読む必要があります。

パラメータをクエリ形式に渡す正しい方法は次のとおりです。

FMResultSet *rs = [db executeQueryWithFormat:@"SELECT name, content FROM projects WHERE id = (?)", projectID];

于 2012-05-28T09:36:17.417 に答える