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 03-21-2010, 12:59 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Arrow Data's won't reload after DB change (Solved)

Hello everyone,

I have a little problem with my Sqlite app. I'm showing on my main screen some text from the table "x" in the field "y". Now i'm trying to show text from the same table but from a different field wich is not created. I create it and add some text, then test it on the iPhone simulator and I get the error :

No such column : "nameOfMyTab"..

Do I have to do something to let xCode know that I modified my database ?
p.s (I'm not creating an editable copy of my DB so that can't be the prob)

Thanks alot !

Last edited by snowboarderz69; 03-22-2010 at 11:01 PM.
snowboarderz69 is offline   Reply With Quote
Old 03-21-2010, 03:17 AM   #2 (permalink)
Dr. Touch Cocoa Helpdesk
iPhone Dev SDK Supporter
 
Join Date: Sep 2008
Location: Vienna, Austria
Posts: 537
Send a message via AIM to Oliver Drobnik Send a message via MSN to Oliver Drobnik Send a message via Skype™ to Oliver Drobnik
Default

Quote:
Originally Posted by snowboarderz69 View Post
Hello everyone,

I have a little problem with my Sqlite app. I'm showing on my main screen some text from the table "x" in the field "y". Now i'm trying to show text from the same table but from a different field wich is not created. I create it and add some text, then test it on the iPhone simulator and I get the error :

No such column : "nameOfMyTab"..

Do I have to do something to let xCode know that I modified my database ?
p.s (I'm not creating an editable copy of my DB so that can't be the prob)

Thanks alot !
If you're using CoreCata you have to update the schema to match.
__________________
regards

Oliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.

Linguan – makes localizing strings file fun!

Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!
Oliver Drobnik is offline   Reply With Quote
Old 03-21-2010, 11:04 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

Sadly I am not using core data

Anyone else ? It's for a school project and it have to be done for tomorrow
snowboarderz69 is offline   Reply With Quote
Old 03-21-2010, 11:25 AM   #4 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,578
Default

There's nothing special that needs to be done for xCode to see the new field. Are you sure it's being created successfully?
JasonR is online now   Reply With Quote
Old 03-21-2010, 02:40 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

It's supposed to.. I open my db by clicking the one I see in xCode and I see the new field.. It's very strange =(
snowboarderz69 is offline   Reply With Quote
Old 03-21-2010, 04:47 PM   #6 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,578
Default

Maybe you need to post the code you are using to read the DB. Could be something you are overlooking.
JasonR is online now   Reply With Quote
Old 03-21-2010, 05:21 PM   #7 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

I initialize my database with :
Code:
// Ouvre la base de donnée et récupère les clefs primaire de la table principal
- (void)initializeDatabase {
    NSMutableArray *todoArray = [[NSMutableArray alloc] init];
    self.todos = todoArray;
    [todoArray release];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"todo.sqlite"];
    // Ouvre la base de donnée 
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
        // Trouve les clefs primaires
        const char *sql = "SELECT pk FROM todo";
        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
            while (sqlite3_step(statement) == SQLITE_ROW) {
                int primaryKey = sqlite3_column_int(statement, 0);
                Todo *td = [[Todo alloc] initWithPrimaryKey:primaryKey database:database];
				
                [todos addObject:td];
                [td release];
            }
        }
        sqlite3_finalize(statement);
    } else {
        sqlite3_close(database);
        NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    }
}
I init my view with this code :
Code:
//Initie la vue principal (la liste des étapes) avec les informations de la BD
- (id)initWithPrimaryKey:(NSInteger)pk database:(sqlite3 *)db {
	
	if (self = [super init]) {
        primaryKey = pk;
        database = db;
        if (init_statement == nil) {
            const char *sql = "SELECT text,complete,destination FROM todo WHERE pk=?";
            if (sqlite3_prepare_v2(database, sql, -1, &init_statement, NULL) != SQLITE_OK) {
                NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
            }
        }
        sqlite3_bind_int(init_statement, 1, primaryKey);
        if (sqlite3_step(init_statement) == SQLITE_ROW) {
            self.text = [NSString stringWithUTF8String:(char *)sqlite3_column_text(init_statement, 0)];
			self.destination = [NSString stringWithUTF8String:(char *)sqlite3_column_text(init_statement,2)];
			self.status = sqlite3_column_int(init_statement,1);
        } else {
            self.text = @"Aucun itinéraire";
        }
        sqlite3_reset(init_statement);
    }
    return self;
}

The actual field in problem is "destination"..

is there anything wrong ?
Thanks
snowboarderz69 is offline   Reply With Quote
Old 03-21-2010, 09:16 PM   #8 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

Gotta turn in my project in 12 hours and it won't work. I really tryed everything it's so strange :s
snowboarderz69 is offline   Reply With Quote
Old 03-21-2010, 09:46 PM   #9 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,578
Default

Everything looks fine from here. Could you have a simple misspelling of the column name "destination" in the actual database? I think it might be case sensitive, so "Destination" would not match.
JasonR is online now   Reply With Quote
Old 03-22-2010, 04:06 PM   #10 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

Everything in the Database is fine. There must be something wrong =/
snowboarderz69 is offline   Reply With Quote
Old 03-22-2010, 10:31 PM   #11 (permalink)
Knows SQL
 
iisword's Avatar
 
Join Date: Oct 2009
Location: Somewhere the streets are on fire, the sewers are flooded, and the cats are high on catnip
Posts: 527
Default

Quote:
Originally Posted by snowboarderz69 View Post
Everything in the Database is fine. There must be something wrong =/
For the tableview class, try something like this:

Code:
- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];
	
	[self.tableView reloadData];
}
I forgot to reload the data again when new data is in the table.
__________________
iisword is offline   Reply With Quote
Old 03-22-2010, 11:00 PM   #12 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 10
Default

Damn I just found out what was going on... My select/update/insert/delete statements where STATIC variable so they were keeping the old data's. I should have saw them before !

Thanks alot everyone for your help, I love how people on this forum help each/other, it's nice
snowboarderz69 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: 249
24 members and 225 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Dominus, dre, glenn_sayers, HemiMG, JasonR, karlam963, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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