启动应用程序时无法打开 Sqllite DB 文件

发布于 2024-11-27 03:13:01 字数 600 浏览 2 评论 0 原文

我使用 PostBuildevnt 脚本启动申请表链接

http://blogs.msdn.com/b/astebner/archive/2006/08/12/696833.aspx?wa=wsignin1.0&CommentPosted=true

并成功启动应用程序.我正在使用 sqllite 作为应用程序。 我在应用程序文件夹/数据库中添加了 DB 文件,并使用以下代码打开 Db 文件。

string ConnectionString = "data source=" + Path.GetFullPath(".") + "\\DataBase\\CATTDB.db";

如果我从安装向导启动应用程序,它不会连接到数据库文件。它会抛出类似“无法打开文件”的错误。

如果我从开始菜单或桌面图标启动,它工作正常..

这里有什么问题? 请帮我..

I used the PostBuildevnt script to launch the application form link

http://blogs.msdn.com/b/astebner/archive/2006/08/12/696833.aspx?wa=wsignin1.0&CommentPosted=true

and launching the app successfully.I am using the sqllite for app.
I added the DB file in Application Folder/DataBase and using the following code to open the Db file.

string ConnectionString = "data source=" + Path.GetFullPath(".") + "\\DataBase\\CATTDB.db";

If i launch the app from the installation wizard,it is not connecting to db file.it is throwing the error like "Unable to open the file".

If i launch from the start menu or desktop icon ,it is working fine..

What is the problem here?
please help me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独自唱情﹋歌 2024-12-04 03:13:01

从安装程序启动时,您的工作目录可能会有所不同...

在这种情况下,Path.GetFullPath(".") 返回什么(记录和/或显示值)?

始终存在权限/权限问题 - 取决于您的操作系统(即 Windows 7...)和运行应用程序的用户(ia 管理员?)出于安全原因,您不允许在应用程序目录中写入。如果您需要读+写的地方,您应该使用 http://msdn.microsoft.com/de-de/library/system.windows.forms.application.userappdatapath.aspx

只需检查数据库是否在该路径中 - 如果不是复制它在那里 - 并在那里使用它...

其他位置可能是来自 http://msdn.microsoft.com/de-de/library/14tx8hby.aspxhttp://msdn.microsoft.com/de-de/library/system.environment.specialfolder.aspx

It could be that your working directoy is different when started from the installer...

What does Path.GetFullPath(".") return in this case (log and/or display the value)?

There is always the issue of permission/rights - depending on your OS (i.e. Windows 7...) and the user your running the app with (i.a. Administrator?) for security reasons you are not allowed to write in the application directory... if you need someplace with read+write you should use http://msdn.microsoft.com/de-de/library/system.windows.forms.application.userappdatapath.aspx

Just check whether the db is in that path -if not copy it there- and use it there...

Other locations could be ApplicationData/CommonApplicationData/LocalApplicationData from http://msdn.microsoft.com/de-de/library/14tx8hby.aspx and http://msdn.microsoft.com/de-de/library/system.environment.specialfolder.aspx

莫言歌 2024-12-04 03:13:01

所有文件都正确复制。

我尝试使用 Application.ExecutablePath 而不是 Path.GetFullPath(".")

它工作得很好...

All the files are copying correctly..

I tried with Application.ExecutablePath instead of Path.GetFullPath(".")

it work's great...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文