On Thu, Feb 17, 2011 at 04:01:39PM +0100, Sven L scratched on the wall:
> 
> sqlite3* db = NULL;
> if (sqlite3_open_v2(path, &db, SQLITE_OPEN_READWRITE, NULL) == 
> SQLITE_CANTOPEN)
> {
>     // Ok, database does not exist. Still, db != NULL...?
>     ASSERT(db != NULL);
> }
>  
> Database cannot be opened, but we get an open handle to it... Please explain!

  http://sqlite.org/c3ref/open.html

     ...A database connection handle is usually returned in *ppDb, even if
     an error occurs. The only exception is that if SQLite is unable to
     allocate memory to hold the sqlite3 object, a NULL will be written
     into *ppDb instead of a pointer to the sqlite3 object. If the
     database is opened (and/or created) successfully, then SQLITE_OK
     is returned. Otherwise an error code is returned. The
     sqlite3_errmsg() or sqlite3_errmsg16() routines can be used to
     obtain an English language description of the error following a
     failure of any of the sqlite3_open() routines.


   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to