连接字符串中的临时路径中的 SQLCe 本地数据库?
我的应用程序中有 SQL Ce 数据库,它包含在我的应用程序目录中。调试时一切正常,但当发布并使用 setup.exe 运行时,它会在运行应用程序的临时目录中检索“未找到文件”。我想从标准位置运行,但我不知道如何更改它。
我正在使用这个字符串:
SqlCeConnection connection = new SqlCeConnection("Data Source=database.sdf;Persist Security Info=False;");
当我运行 setup.exe 时,应用程序永远不会启动,说明在其临时目录中找不到 db 文件。当我运行 app.exe 时,它起作用了。我不明白...:(
编辑:我可以看到在VS项目设置中,有连接字符串,并且有“Data Source=|DataDirectory|\Database.sdf”
路径应该是类似本地目录的东西?谢谢!
I have SQL Ce db in my app, which is included in my app directory. While debugging its OK, but when published and run with setup.exe, it retrieves "file not found" in temporary directory the app is ran from. I would like to run from standard location, but I dont know how to change it.
I am using this string:
SqlCeConnection connection = new SqlCeConnection("Data Source=database.sdf;Persist Security Info=False;");
When I run setup.exe, the app never starts, stating that in its temporary directory the db file was not found. When I run app.exe, it works. I do not understand it...:(
EDIT: I can see that in the VS project settings, there is connection string and there is "Data Source=|DataDirectory|\Database.sdf"
The path should be something like local directory? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
动态构建连接字符串。像这样的东西:
Build your connection string dynamically. Something like this: