EGODatabase does not retain inserted record

Posted by user135775 on Stack Overflow See other posts from Stack Overflow or by user135775
Published on 2010-05-11T16:16:33Z Indexed on 2010/05/11 16:24 UTC
Read the original article Hit count: 187

Filed under:
|
|

Hi Guy!

I'm using EGODatabase to process my data. When I tried to insert data into the database which I created with Base and attached to the project, the data that was inserted programmatically will not show up when I restart my app.However the data inserted manually using Base will show up just fine.

Following is the code for inserting data into the database:

 NSString *path = [[NSBundle mainBundle] pathForResource:@"Database" ofType:@"db"]; 
    db = [EGODatabase databaseWithPath:path]; 
    if ([db open]) { 
        NSLog(@"Database is opened successfully!"); 
    } else { 
        NSLog(@"Database is failed to open!"); 
    } 

    NSArray *params = [NSArray arrayWithObjects:[aFeed feedID], [aFeed title], nil]; 
    [db executeUpdate:@"Insert INTO Feed (FeedID, Title) VALUES (?, ?)" parameters:params];
    EGODatabaseResult *results = [db executeQuery:@"SELECT * FROM Feed"];
    for ( EGODatabaseRow * row in results) {
        NSLog(@"ID: %@      Title: %@", [row stringForColumn:@"FeedID"], [row stringForColumn:@"Title"]);
    } 

I appreciate if anyone can share me a working sample code for EGODatabase. I'm using EGODatabase because I might have multi-threading code that write to the database. Thank in advance.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c