部署路径问题 [英] Deployment path issue
问题描述
我在项目中使用哪条路径
在我的项目解放后,软件找不到数据库文件
我的尝试:
Dim con As New OleDbConnection(Provider = Microsoft.ACE.OLEDB.12.0; Data Source = D:\ sunil \ hardware date.vb \ hardware.vb \ hardware.accdb)
Dim con As String =(Provider = Microsoft .ACE.OLEDB.12.0;数据源= + Application.StartupPath + \..\ hardware.accdb)
which path i am use in project
after depled my project that time software not found database file
What I have tried:
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\sunil\hardware date.vb\hardware.vb\hardware.accdb")
Dim con As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= + Application.StartupPath + \..\hardware.accdb")
推荐答案
假设您已部署数据库将文件放到与应用程序相同的文件夹中,在连接字符串中使用| DataDirectory |
指向该目录:
Assuming you've deployed the database file to the same folder as your application, use|DataDirectory|
in your connection string to point to that directory:
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\hardware.accdb")
然而,如果您的应用程序安装在Program Files文件夹下,然后它将无权更新数据库文件,除非你提升它(右键单击,以管理员身份运行)。
However, if your application is installed under the "Program Files" folder, then it will not have permission to update the database file unless you run it elevated (right-click, "Run as administrator").
这篇关于部署路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!