c# - how to connect silverlight with sqlite without IsolatedStorageFile -


isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication();  isf.deletefile("mydb.db");  using (sqliteconnection conn = new sqliteconnection()) {     conn.connectionstring = "version=3,uri=file:mydb.db";     conn.open();      using (sqlitecommand cmd = conn.createcommand())     {           cmd.commandtext = "create table test_table ( [id] integer primary key, [col] integer unique, [col2] integer, [col3] real, [col4] text, [col5] blob)";         cmd.executenonquery();          cmd.transaction = conn.begintransaction();         cmd.commandtext = "insert test_table(col, col2, col3, col4, col5) values(@col, @col2, @col3, @col4, @col5);select last_insert_rowid();";         cmd.parameters.add("@col", null);         cmd.parameters.add("@col2", null);         cmd.parameters.add("@col3", null);         cmd.parameters.add("@col4", null);         cmd.parameters.add("@col5", null);          datetime start = datetime.now;         this.lstresult.items.add("inserting 100 rows transaction");          (int = 0; < 100; i++)         {             cmd.parameters["@col"].value = i;             cmd.parameters["@col2"].value = i;             cmd.parameters["@col3"].value = * 0.515;             cmd.parameters["@col4"].value = "hello world" + i;             cmd.parameters["@col5"].value = encoding.utf8.getbytes("test");              object s = cmd.executescalar();         }         cmd.transaction.commit();         cmd.transaction = null;         this.lstresult.items.add("time taken :" + datetime.now.subtract(start).totalmilliseconds + " ms.");          cmd.commandtext = "select * test_table";         using (sqlitedatareader reader = cmd.executereader())         {             while (reader.read())             {                 var bytes = (byte[])reader.getvalue(5);                 this.lstresult.items.add(string.format("{0},{1},{2},{3},{4}, {5}",                     reader.getint32(0),                     reader.getint32(1),                     reader.getint32(2),                     reader.getdouble(3),                     reader.getstring(4),                     encoding.utf8.getstring(bytes, 0, bytes.length)));             }         }          conn.close();     } } 

this code works good, there anyway connect database on d: drive

conn.connectionstring = @"version=3,uri=file:d:\mydb.db"; 

or other way connect type of databases without using isolatedstoragefile

is database on server or users computer?

if on server, want create wcf service accesses database, have silverlight interact wcf service.

if on users computer, cannot access local file system directly. need present user openfiledialog. user select file, made available filestream on openfiledialog.

if silverlight oob app, things change little bit. have more access user's system, i'm not familiar enough silverlight oob make recommendations.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -