Here is my code, written in Obj-C.  I can't figure out what I'm doing 
wrong... can someone enlighten me?  Please?

     NSString * errmsg = nil;
     SQLiteDB* db = [SQLiteDB sharedSQLiteDB];  //  create the d/b

     NSString *insertCommand = [NSString stringWithFormat:@"INSERT FAIL 
INTO CardData (CARD_ID, CARD_NAME, CODE_VAL) VALUES ('/%@', '/%@', 
'/%@')", symbol.data, @"Test Card", symbol.typeName];

     sqlite3_exec(db, [insertCommand UTF8String], NULL, NULL, &errmsg);
     if(errmsg != NULL)
         NSLog(@"insert error: /%@", &errmsg);  //  DEBUGGING ONLY!

     //  now, pull it back out of the d/b and display the data
     NSString *sqlStatement = @"SELECT card_id, card_name, code_val FROM 
CardData";
     sqlite3_stmt *compiledStatement;
     int err = sqlite3_prepare_v2(db, [sqlStatement UTF8String], -1, 
&compiledStatement, NULL); // <-----------  error 21 occurs here
     if(err != SQLITE_OK)
        NSLog(@"prepare error: /%@", err);
     else  {
         // Loop through the results and add them to the feeds array
         while(sqlite3_step(compiledStatement) == SQLITE_ROW) {

             // Read the data from the result row
             resultText.text = [NSString stringWithFormat:@"\nDatabase: 
\n%@ \n%@ \n%@", resultText.text,
                 [NSString stringWithUTF8String:(char 
*)sqlite3_column_text(compiledStatement, 0)],
                 [NSString stringWithUTF8String:(char 
*)sqlite3_column_text(compiledStatement, 1)],
                 [NSString stringWithUTF8String:(char 
*)sqlite3_column_text(compiledStatement, 2)]];
         }
         sqlite3_finalize(compiledStatement);  //  release it...
         sqlite3_close(db);
     }
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to