[英]VB.NET with MS access Database as backend how to deploy by putting Database file to AppData Folder?
i have developed VB.NET application using MS access DB as backend, at development and testing i have been using this connection string 我已经使用MS Access DB作为后端开发了VB.NET应用程序,在开发和测试中我一直在使用此连接字符串
Dim connect_string As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\data.accdb"
as deployment to client's machines, database must be outside of program files, so how do i deploy this application by separating database from program files. 作为部署到客户端计算机的数据库,数据库必须位于程序文件之外,因此我如何通过将数据库与程序文件分开来部署此应用程序。 ?
?
You use 你用
Environment.GetFolderPath(Environment.SpecialFolder.XXXX)
to find a suitable root directory, and add something like YourCompanyName\\YourApplicationName
to it. 查找合适的根目录,并向其中添加类似
YourCompanyName\\YourApplicationName
。 For XXXX, you use either ApplicationData
, or LocalApplicationData
, or CommonApplicationData
, depending on your requirements (see here). 对于XXXX,您可以根据需要使用
ApplicationData
, LocalApplicationData
或CommonApplicationData
(请参见此处)。 Or you let your user configure a local or network path, for example in a config file. 或者,您可以让用户配置本地或网络路径,例如在配置文件中。
How your "initial database" gets there is up to your program. 您的“初始数据库”如何到达那里取决于您的程序。 For example, you could test if at there is a database file at the desired place and copy an empty template MDB into the folder if there is none.
例如,您可以测试所需位置是否有数据库文件,如果没有,则将一个空模板MDB复制到该文件夹中。 The template DB could be either in your program's installation directory, or embedded into the resources of your exe files, or you create it "on-the-fly" using DAO or ADO (do not know if that's possible by ADO.NET).
模板DB可以位于程序的安装目录中,也可以嵌入exe文件的资源中,或者您可以使用DAO或ADO“即时”创建它(不知道ADO.NET是否可以实现)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.