VistaDB 5
Working with a database in isolated storage

Working with ADO.NET and Isolated Storage


Creating a database

Create a Database in Isolated Storage
Copy Code
using( VistaDBConnection conn = new VistaDBConnection() )
{
   using( VistaDBCommand cmd = conn.CreateCommand() )
   {
      cmd.CommandText = "CREATE DATABASE testdatabase.vdb4 IN ISOLATED STORAGE";
      cmd.ExecuteNonQuery();
      conn.Close();
   }
} 

Opening a database

You must add the following to your connection string if the database is in isolated storage: Isolated Storage = true;

Opening a Database in Isolated Storage
Copy Code
using (VistaDBConnection conn = new VistaDBConnection("Data Source = isolatedDatabase.vdb4; Isolated Storage = true; Open Mode = ExclusiveReadWrite"))
{
  conn.Open();
}

Working with DDA and Isolated Storage

Create a database

Creating a Database through DDA in Isolated Storage
Copy Code
IVistaDBDDA DDAObj = VistaDBEngine.Connections.OpenDDA();
DDAObj.CreateIsolatedDatabase(dbname, null, 1, 0, false);

Opening a database

Opening a Database in Isolated Storage (DDA)
Copy Code
IVistaDBDatabase db = DDAObj.OpenIsolatedDatabase(dbName, VistaDBDatabaseOpenMode.ExclusiveReadWrite, null);