Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-22-2009, 09:13 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 20
Unhappy Annoyance with SQLite3

Hi,
I have a strange problem with sqlite3.

Code:
NSString *queryStatementNS = "drop table \"myTABLE\"";
const char *queryStatement = [queryStatementNS UTF8String];
if(sqlite3_prepare_v2 (db, queryStatement, -1, &dbps, NULL) == SQLITE_OK)
{
if(sqlite3_step (dbps) == SQLITE_OK)
{
}
else
{
NSLog(@"SQL step failed code: %d", sqlite3_step (dbps));
NSLog(@"Attempted Query: %@", queryStatementNS);
}

sqlite3_finalize (dbps);
sqlite3_close(db);
}

Output:
SQL step failed code: 21
Attempted Query: drop table "myTABLE"

I often get this error. Is the syntax wrong ? I checked online which says error 21 means SQLITE_MISUSE.

I thought this error would come up only when we have special characters in the query.

What am I doing wrong ?

Plz help.

Thanks.

Last edited by cation007; 07-22-2009 at 09:16 PM. Reason: missing information
cation007 is offline   Reply With Quote
Old 07-24-2009, 10:04 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 370
Default

Quote:
NSString *queryStatementNS = "drop table \"myTABLE\"";
use :
NSString *queryStatementNS = "drop table myTABLE";


no need double quotes..
david_david is offline   Reply With Quote
Old 07-25-2009, 02:10 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 20
Default

Quote:
Originally Posted by david_david View Post
use :
NSString *queryStatementNS = "drop table myTABLE";


no need double quotes..
That fives problems with strings with special characters and spaces.

Although, it give me an error code of 21, its still executing. So, I am ignoring the error.

Thanks neways.
cation007 is offline   Reply With Quote
Old 07-25-2009, 02:24 AM   #4 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 370
Default

the statements like create, drop execute like:

Code:
NSString *queryStatementNS = "drop table  myTABLE";

if (sqlite3_exec(database, [queryStatementNS UTF8String], NULL, NULL, NULL) == SQLITE_OK) {
			
			NSLog(@" table deleted");
}else{
			MELog(@"noooo");
}
david_david is offline   Reply With Quote
Reply

Bookmarks

Tags
error, sqlite3

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 251
23 members and 228 guests
@sandris, ADY, beleg_1998, Dani77, diyora, FAED, fredidf, F_Bryant, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0