2010-08-23 2 views
8

실행 내가 21 "라이브러리 루틴 순서의 부르심"는 SQLLite 오류를 얻을 sqlite3를 DB-selecct의 쿼리 문을 준비하십시오sqlite3를이 - 라이브러리 루틴 순서가 호출

sqlite3    *lDb; 
sqlite3_stmt   *lStmt; 
NSNumberFormatter  *lNbrFmt = [[[NSNumberFormatter alloc] init] autorelease]; 

// Define SQL statement 
NSString *lSql = @"SELECT section, language, title, description" 
@"      selector-x-pos, selector-y-pos, gps-x-pos, gps-y-pos" 
@"     FROM sections" 
@"    ORDER BY section ASC"; 

lSqlResult = sqlite3_prepare_v2(lDb, [lSql UTF8String], -1, &lStmt, NULL); 
NSLog(@"%@", [NSString stringWithUTF8String:sqlite3_errmsg(lDb)]); 

무엇 오전 내가 잘못하고있어?

+0

축하 그것을 파악에! 레거시에 대한 질문과 답변을 재 형식화하여 향후 방문자가 쉽게 동일한 오류를 해결할 수 있도록 할 수 있습니까? 그렇지 않은 경우 질문을 모두 삭제해야합니다. 감사! – MPelletier

+1

걱정하지 말고 그냥 편집했습니다 ... – iFloh

답변

10

추가 조사 Uopon 내 실수를 발견했습니다. prep 문을 실행하기 전에 먼저 db를 열어야했습니다.

코드는 다음과 같아야합니다

sqlite3    *lDb; 
sqlite3_stmt   *lStmt; 
NSNumberFormatter  *lNbrFmt = [[[NSNumberFormatter alloc] init] autorelease]; 

// Define SQL statement 
NSString *lSql = @"SELECT section, language, title, description" 
@"      selector-x-pos, selector-y-pos, gps-x-pos, gps-y-pos" 
@"     FROM sections" 
@"    ORDER BY section ASC"; 

if(sqlite3_open([[fileMethods databasePath] UTF8String], &lDb) == SQLITE_OK) { 
    lSqlResult = sqlite3_prepare_v2(lDb, [lSql UTF8String], -1, &lStmt, NULL); 
    NSLog(@"%@", [NSString stringWithUTF8String:sqlite3_errmsg(lDb)]); 
... 
+0

"라이브러리 루틴이 순서가 잘못되었습니다."- 또는 다른 곳에서 이미 동일한 DB가 열려 있지 않은지 확인하십시오. 포인터 주셔서 감사합니다;) – Luke