Before Beta 2 came out I had been reading that SQL Mobile databases and the System.Data.SqlServerCe namespace would work from the full .NET 2 framework. Once I actually tried this I could find very little conversation on the subject, except for here. I tried exactly what this author had done and I was getting all kinds of assembly loading errors. I was finally able to access a .sdf database from my winforms app, but I'm not happy with the solution.
Beta 2 installs several System.Data.SqlServerCe .Dll files. The one that will actually load from a desktop winforms application is in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\, with a description of "Microsoft SQL Mobile" and version 9.0.242.0. When I tried this at first, I was still getting errors thrown out of this assembly with descriptions like "sqlcese.sys.dll". In the same IDE directory mentioned above there are several .DLL files with similar names. I was ultimately able to get my SqlCe connection to work by copying some of these to my application's bin\Debug directory:
- sqlceca30.dll
- sqlcecompact30.dll
- sqlceer30en.dll
- sqlceme30.dll
- sqlceoledb30.dll
- sqlceqp30.dll
- sqlcese30.dll
This is the part I'm not happy with. The fact that the .DLL that works is in a visual studio directory and apparently needs some other DLLs from the same to run probably means one of two things. Either my Beta 2 installation is slightly funky, or Sql Mobile from Full framework is not going to be something you can do on a computer without Visual Studio installed. I hope the latter is not the case. It would be very nice to be able to use Sql Mobile instead of access, and also to be able to use the power of a desktop PC to build .SDF databases. I have not messed with the bulk copy functionality in Sql Server 2005 yet, so perhaps that is easy to automate. Again though, this implies you should be able to use a .SDF datbase from desktop code.