views:

107

answers:

2

I have a .Net application which must store all it's 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.

  1. Is it possible to use isolated storage to store a SQL CE database?

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

A: 

It appears that SqlCe does not support isolated storage. See these questions.

http://stackoverflow.com/questions/108399/what-embedded-database-with-isolated-storage... http://stackoverflow.com/questions/55273/what-are-the-advantages-of-vistadb

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

MusiGenesis
A: 

SQL Server CE doesn't directly support this; you'd have to use a different product. In addition to VistaDB, you could 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 at the full path of an Isolated Storage file, and use the result in a connection string, although I would guess that if you're required to use Isolated Storage then your application is not running under full trust. And even if it is, it's still a dangerous thing to do. Still, if you get really desperate, you could have a look at this thread that has an example, which involves creating a stream and reflecting on one of the private fields of the stream that contains the file name.

Aaronaught