简体   繁体   中英

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

 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. For XXXX, you use either ApplicationData , or LocalApplicationData , or CommonApplicationData , depending on your requirements (see here). 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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM