Hello everyone,
I recently started exploring around with Monodroid and now I wanted to work
with databases.
Finally I got that working, but what I want now is I made an database with
SQLite database browser.. and I want that file(database) to be deployed onto
the machine so that I can use the already existing data inside that
database.. but how do I get that to work from scratch?
Someone told me about Assets but how do I get the path of the asset file?
I've got the following to connect to a database now:
public static SqliteConnection GetConnection()
{
var documents =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string db = Path.Combine(documents, "items.db3");
bool exists = File.Exists(db);
if (!exists)
SqliteConnection.CreateFile(db);
var conn = new SqliteConnection("Data Source=" + db);
if (!exists)
{
var commands = new[] {
"CREATE TABLE Items (Key ntext, Value ntext)",
"INSERT INTO [Items] ([Key], [Value]) VALUES ('sample', 'text1')",
"INSERT INTO [Items] ([Key], [Value]) VALUES ('sample2',
'text2')",
"INSERT INTO [Items] ([Key], [Value]) VALUES ('sample3',
'text3')",
};
foreach (var cmd in commands)
WithCommand(c =>
{
c.CommandText = cmd;
c.ExecuteNonQuery();
});
}
return conn;
}
*Thanks in advance,*
*
*
-- Mittchel
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid