Obviously I need to write a Sqlite sample...
On Aug 10, 2011, at 10:58 AM, vsr28 wrote:
> Can any one say , how to connect a sqlite database with monodroid? When i
> try to connect it showing some errors like, “Unable to open database” in the
> con.Open line.
So what's your connection string? I know that this works:
var dbPath = Path.Combine (
Environment.GetFolderPath
(Environment.SpecialFolder.Personal),
FileName);
bool exists = File.Exists (dbPath);
if (!exists) {
SqliteConnection.CreateFile (dbPath);
}
var conn = new SqliteConnection ("Data Source=" + dbPath);
if (!exists) {
// add entries to the DB
}
conn.Open ();
// ...
That will open a file relative to `/data/data/YOUR_PACKAGE_NAME/files`, though
you'll need to ensure that the file exists before calling SqliteConnection.Open
(e.g. the above calls SqliteConnection.CreateFile() if it doesn't exist).
See also:
http://lists.ximian.com/mailman/private/monodroid/2011-January/002616.html
> Actually i have already created SQLite database and i need to fetch records
> of it.
Then you'll need to make sure that your "already created SQLite database" is
present on the filesystem (e.g. if you're embedding it as a resource, you'll
need to copy it to disk first).
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid