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-29-2010, 06:57 PM   #1 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
Send a message via AIM to lifeCoder45
Default Quick Sqlite Question

Hey guys, I have a quick question. I'm trying to build an sql query using an int, so I'm doing string w/ format, but apparently sqlite3_prepare_v2 wants a const char* as it's query string, not an NSString. How can I get around this?

Code:
NSUInteger row = [indexPath row];
NSString *sqlStatement = [[NSString alloc] initWithFormat:@"UPDATE `configuration` SET `currency`='%d' WHERE `id`='1'",row];
		
sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL);
My error is: "warning: passing argument 2 of 'sqlite3_prepare_v2' from incompatible pointer type"

Thanks,

Josh.
lifeCoder45 is offline   Reply With Quote
Old 07-29-2010, 07:38 PM   #2 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
Send a message via AIM to lifeCoder45
Default

Never mind, I was going about it the wrong way.

Here is my new code, if anyone is interested:

Code:
if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK) {
		
		static sqlite3_stmt *updateStmt = nil;
		
		if(updateStmt == nil) {
			
			const char *sql = "update configuration Set currency = ? where id=1";
			sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL);
			
		}
		
		sqlite3_bind_int(updateStmt, 1, row);
		
		sqlite3_step(updateStmt);
		
		sqlite3_reset(updateStmt);
		
	}//end if
lifeCoder45 is offline   Reply With Quote
Old 07-29-2010, 09:05 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 253
Default

check..

(sqlite3_prepare_v2(database, sql, -1, &deleteStmt, NULL) != SQLITE_OK)

or

sqlite3_bind_text(stmt, 1, [namefav UTF8String], -1, SQLITE_TRANSIENT);
gunther is offline   Reply With Quote
Reply

Bookmarks

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: 262
20 members and 242 guests
ADY, Alsahir, beleg_1998, Dani77, e2applets, iph_s, JasonR, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, Rudy, sly24, smithdale87, timle8n1, Touchmint, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,758
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:22 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0