Is there a way to save and access a SQL CE (.sdf) database in isolated storage?

I have a .Net application that needs to store all local data in isolated storage. I want to start using SQL CE to store this data. I can't find any documentation on how (or even if) this is possible.

  • Can I use isolated storage to store a SQL CE database?

  • If so, what would the connection string look like (or is there some other way to open the database)?

+2


a source to share


2 answers


It looks like SqlCe does not support isolated storage. See these questions.

fooobar.com/questions/633519 / ... What are the advantages of VistaDB



VistaDB looks like the best choice. Or you can set up some kind of hack where you use the IS API to copy the SDF file (SQlCe) from isolated storage to a location in the normal filesystem where you can interact with it normally, and then copy the SDF file back to the IS. This pretty much defeats the goal of isolated storage, so I wouldn't recommend it.

+1


a source


SQL Server CE does not directly support this; you will have to use a different product. In addition to VistaDB, you can also use db4o if you don't need a relational database (it's an object database and has an isolated storage wrapper).



You can technically use Reflection to get the full path to the isolated storage file and use the result in the connection string, although I would assume that if you need to use isolated storage your application will not run under full trust. And even if it is, it is still dangerous. That said, if you are really desperate, you could take a look at this stream , which has an example that involves creating a stream and reflecting on one of the stream's private fields that contains the filename.

0


a source







All Articles