Problem in OpenDatabase()

May 7, 2010 at 4:17 PM

Hello, in first of all, very compliments for your job!

I try to make an WP7 app...but in my code when I call one my method (I've addes Exists method):

if (!Database.Exists("test"))
    t_db = Database.CreateDatabase("test");
else
    t_db = Database.OpenDatabase("test");

Database.OpenDatabase("test") throws an Exception:

# Operation not permitted on IsolatedStorageFileStream.

# StackTrace:
   at SilverlightPhoneDatabase.Database.OpenDatabase(String databaseName, String password, Boolean useLazyLoading)
   at SilverlightPhoneDatabase.Database.OpenDatabase(String databaseName)
   at MyNs.Business.BaseBusiness.GetDbSession()
   at MyNs.Business.BaseBusiness.GetTable[T]()
   at MyNs.Business.BaseBusiness.List[T]()
   at MyNs.Default.BindLstBox()
   at MyNs.Default.Default_Loaded(Object sender, RoutedEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

May 7, 2010 at 4:30 PM

I've resolved.

When I call Database.CreateDatabase("test"), I need to call Save().

 

It's correct?

May 7, 2010 at 7:46 PM

Absolutely.  You have to save DB after all manipulations, whether definition or data. Also, unit test project included should have good example of most things you would do with DB.

Thanks.

Sergey