Discussion:
Getting an error 21 when doing a sqlite3_prepare_v2
Rolf Marsh
2011-05-03 13:46:53 UTC
Permalink
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);
}
Richard Hipp
2011-05-03 13:52:19 UTC
Permalink
Post by Rolf Marsh
Here is my code, written in Obj-C. I can't figure out what I'm doing
wrong... can someone enlighten me? Please?
Set a breakpoint on sqlite3MisuseError() and see where it is being hit.
Post by Rolf Marsh
NSString * errmsg = nil;
SQLiteDB* db = [SQLiteDB sharedSQLiteDB]; // create the d/b
sqlite3_exec(db, [insertCommand UTF8String], NULL, NULL, &errmsg);
if(errmsg != NULL)
// now, pull it back out of the d/b and display the data
CardData";
sqlite3_stmt *compiledStatement;
int err = sqlite3_prepare_v2(db, [sqlStatement UTF8String], -1,
&compiledStatement, NULL); // <----------- error 21 occurs here
if(err != SQLITE_OK)
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
[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
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--
D. Richard Hipp
drh-CzDROfG0BjIdnm+***@public.gmane.org
Rolf Marsh
2011-05-03 14:29:12 UTC
Permalink
Good Morning Richard... thanks for the response... after making the
change you suggested and when doing the build, I get the following error:




l "_sqlite3MisuseError", referenced from:
-[PointPeekViewController
imagePickerController:didFinishPickingMediaWithInfo:] in
PointPeekViewController.o
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status

This is an iPhone app, using XCode 4 for the build...

Regards,
Rolf
Post by Richard Hipp
Post by Rolf Marsh
Here is my code, written in Obj-C. I can't figure out what I'm doing
wrong... can someone enlighten me? Please?
Set a breakpoint on sqlite3MisuseError() and see where it is being hit.
Post by Rolf Marsh
NSString * errmsg = nil;
SQLiteDB* db = [SQLiteDB sharedSQLiteDB]; // create the d/b
sqlite3_exec(db, [insertCommand UTF8String], NULL, NULL,&errmsg);
if(errmsg != NULL)
// now, pull it back out of the d/b and display the data
CardData";
sqlite3_stmt *compiledStatement;
int err = sqlite3_prepare_v2(db, [sqlStatement UTF8String], -1,
&compiledStatement, NULL); //<----------- error 21 occurs here
if(err != SQLITE_OK)
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
[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
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Richard Hipp
2011-05-04 10:46:29 UTC
Permalink
Post by Rolf Marsh
Good Morning Richard... thanks for the response... after making the
-[PointPeekViewController
imagePickerController:didFinishPickingMediaWithInfo:] in
PointPeekViewController.o
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status
PointPeekViewController is not a part of SQLite, so something else is
seriously wrong here.
Post by Rolf Marsh
This is an iPhone app, using XCode 4 for the build...
Regards,
Rolf
Post by Richard Hipp
Post by Rolf Marsh
Here is my code, written in Obj-C. I can't figure out what I'm doing
wrong... can someone enlighten me? Please?
Set a breakpoint on sqlite3MisuseError() and see where it is being hit.
Post by Rolf Marsh
NSString * errmsg = nil;
SQLiteDB* db = [SQLiteDB sharedSQLiteDB]; // create the d/b
sqlite3_exec(db, [insertCommand UTF8String], NULL, NULL,&errmsg);
if(errmsg != NULL)
// now, pull it back out of the d/b and display the data
CardData";
sqlite3_stmt *compiledStatement;
int err = sqlite3_prepare_v2(db, [sqlStatement UTF8String], -1,
&compiledStatement, NULL); //<----------- error 21 occurs here
if(err != SQLITE_OK)
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
[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
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--
D. Richard Hipp
drh-CzDROfG0BjIdnm+***@public.gmane.org
Loading...