Ngugi1 / sqlite-net

Automatically exported from code.google.com/p/sqlite-net
0 stars 0 forks source link

Throws exception on device #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create a sqliteconnection
2. Attempt to connect to it on the device
3. Exception thrown from line 78 in sqlite.cs: Could not open database
file, the error code is 14.

It seems like the issue is that the database does not exist, but this same
code works on the emulator. Is there something special that has to be done
to make it work on the device?

Thanks!

Original issue reported on code.google.com by roman...@gmail.com on 5 Jun 2010 at 5:13

GoogleCodeExporter commented 9 years ago
As a quick fix, after Handle = handle; in the constructor I added:

if( r == SQLite3.Result.CantOpen )
{
     Mono.Data.Sqlite.SqliteConnection.CreateFile( databasePath );
     r = SQLite3.Open( DatabasePath, out handle );
}

And added: CantOpen = 14 to SQLite3.Result

But would be better to fix it correctly!

Original comment by roman...@gmail.com on 5 Jun 2010 at 10:54

GoogleCodeExporter commented 9 years ago
You can only open *writable* database files. On the iPhone, only the Documents 
directory is writable. Make sure to put your database there.

Environment.GetFolder(SpecialFolder.MyDocuments)

I am keeping the issue open so that I remember to add the error code.

Original comment by frank.al...@gmail.com on 29 Jun 2010 at 6:58

GoogleCodeExporter commented 9 years ago
The strange thing is that the code I added executes correctly which means the 
path is writable doesnt it?

I am using SpecialFolder.Personal

Original comment by roman...@gmail.com on 18 Jul 2010 at 5:22