[英]How to package .sdf Database Application on CD and run without installing on machines
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. 我在后端使用SQL Server CE在C#.Net上创建了Windows应用程序。 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.
我希望将应用程序打包在CD中,这样我的用户就不会安装它,而只会插入并使用该应用程序。
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. 我已经构建了应用程序,并将数据库文件,应用程序文件,配置文件,清单文件和.dll文件复制到一个文件夹中,然后将其压缩。 Then copied the zipped folder to a CD ROM and run on a different system.
然后将压缩的文件夹复制到CD ROM并在其他系统上运行。
On the System I installed SQL Server CE Runtime installer. 在系统上,我安装了SQL Server CE Runtime安装程序。 The Application executed successfully but when I attempted to submit a Form that is connected to the .sdf database the following exception was thrown:
应用程序成功执行,但是当我尝试提交连接到.sdf数据库的表单时,引发了以下异常:
The path is not valid. 路径无效。 Check the directory for the database.
检查数据库目录。 [Path = C:\\Users\\John\\AppData\\Temp\\Temp2_App.zip\\App\\Data\\abc.sdf]
[路径= C:\\ Users \\ John \\ AppData \\ Temp \\ Temp2_App.zip \\ App \\ Data \\ abc.sdf]
My Application Connection String at App.Config is: 我在App.Config上的应用程序连接字符串是:
<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.
请帮我。
Well, in the quest to finding a solution to the problem I have modified the App.Config Connection String to: 好吧,为了寻求解决问题的方法,我将App.Config连接字符串修改为:
<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].
[文件名= E:\\ App \\ Data \\ abc.sdf]。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.