How to package .sdf Database Application on CD and run without installing on machines

69 Views Asked by At

I am having a challenge that is specifically unique to me. I have browse the questions and answers catalog and what i found does not specifically address my scenario.

I created Windows Application on C#.Net with SQL Server CE at the back-end. I want the Application to be packaged in CD in such a way that my User will not install it rather will just insert and use the Application.

I have build the Application and copied the DB file, Application File, Configuration Files, Manifest Files and the .dll files to a folder and zipped it. Then copied the zipped folder to a CD ROM and run on a different system.

On the System I installed SQL Server CE Runtime installer. The Application executed successfully but when I attempted to submit a Form that is connected to the .sdf database the following exception was thrown:

The path is not valid. Check the directory for the database. [Path = C:\Users\John\AppData\Temp\Temp2_App.zip\App\Data\abc.sdf]

My Application Connection String at App.Config is:

<connectionString> 
     <add name="MyApp.Properties.Settings.MyAppConnectionString"
     connectionString="DataSource =|DataDirectory\\abc.sdf|"
     providerName="Microsoft.SqlServerCe.Client.3.5 />"
</connectionString>

The Connection Strings I used in my codes is:

string conString = "Data Source=|DataDirectory|\\Data\\abc.sdf";

Please what is it that I am getting wrong. Please help me.

1

There are 1 best solutions below

0
On

Well, in the quest to finding a solution to the problem I have modified the App.Config Connection String to:

<connectionString> 
     <add name="MyApp.Properties.Settings.MyAppConnectionString"
     connectionString="DataSource =|DataDirectory|\\Data\\abc.sdf"
     providerName="Microsoft.SqlServerCe.Client.3.5 />"

And when I executed the Application on a user Machine it flag the exception - Access to the database file is not allowed. [File name = E:\App\Data\abc.sdf].