On Feb 27, 2009, at 7:56 AM, James Cicenia wrote:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"whatsfresh.sql"];
        
        int cntv = 0;
        int cntf = 0;
        
        ProduceItem *item=nil;
        if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
        // Get the primary key for all books.
const char *sql = "SELECT type, subtype, name, id FROM ProduceItem ORDER BY name";
        sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {

It does get to the second If statement so it did find the database. But then evidently it is not SQLITE_OK on my device in regards to that last if.

Have you checked to see if the file at path actually exists?

The documentation for sqlite3_open() indicates that it will quite happily create a band new empty database if one doesn't exist at the path.

Have a look at the SQLite Book List example (http://developer.apple.com/iphone/library/samplecode/SQLiteBooks/listing4.html ) as it demonstrates testing for the database file and then copying it into the writable location, as necessary.

b.bum


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to