Create an application setting of type string with user scope. Then capture the database location via an OpenFileDialog and save the path in the setting.
To Save the Setting:
If Open_File_Dialog_Set_Database.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
My.Settings.dbpath = Open_File_Dialog_Set_Database.FileName
My.Settings.Save()
MessageBox.Show("Database path has been saved as " & My.Settings.dbpath, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
....
End If
Once captured use as follows:
Using con As New OleDb.OleDbConnection
con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;" & _
"Data Source = " & My.Settings.dbpath
con.Open()
.....
con.Close()
End Using
Keep in mind that the database must be shared where you have read/write permissions if you want to make changes to the database.