Thursday, March 22, 2012

Deployment of SQLce - DATASOURCE issue

My connection string is simply

Data Source ="|DataDirectory|\Data\Test.sdf"; Password ="test";

and it runs just fine...

I did a simple publish (simple public, no checking for updates or anything)

When the public completes I run the install app. I get the following odd error during install:

************** Exception Text **************
The path is not valid. Check the directory for the database. [ Path = C:\Documents and Settings\jlibertor\Local Settings\Apps\2.0\Data\DZN9D6Y7.8E9\N0WB27KY.XZB\test..tion_b3b178185207c0b7_0001.0000_ef52a43c912d4680\Data\Data\Test.sdf ]

So... any ideas? thansk so much in advance!

have you tried;

Data Source ="|DataDirectory|\Test.sdf"; Password ="test";

Otherwise you can possibly override by using: AppDomain.Setdata

|||

OK I figured it out. ther were 2 reasons...

And if thsi helps anyone I'll past a few things:

You can set the DataDirectory using this code:

AppDomain.CurrentDomain.SetData("DataDirectory", System.AppDomain.CurrentDomain.BaseDirectory)

Place it in the application startup event.

Tip: you can't use the "My.StartupPath" in the event, and instead have to use "System.AppDomain.CurrentDomain.BaseDirectory"

ALSO

Don't forget that if you are getting this error you may not be publishing your .sdf file! (This my problem too) There are SEVERAL things you need to change in order to publich your file.

Tip: A good way to test if you are really publishign your .sdf file to check your publish package for it.

1-Set the properties of the .sdf file to "Content" and Output to "Copy Always"

2-In your Publish settings, look for yoru .sdf file. and force it to incluce.

Tip: After your user installs this once you don't want to publish it again. You'll want to change the above settings and supress this file (otherise you'll overwrite all of their hard-earned data )

No comments:

Post a Comment