Saedawke
Saedawke

Reputation: 471

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. ?

Upvotes: 1

Views: 217

Answers (1)

Saedawke
Saedawke

Reputation: 471

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).

Upvotes: 1

Related Questions