i am using "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\My PC\Desktop\MOMS 3\MOMS2\WindowsApplication2\MOMS.accdb" This is the path to connect with the database. can you one tell me any other way i can use instead of this. I want to use the program on other computers. I tried "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|Data Directory|\MOMS.accdb" and "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & application.startuppath & "\MOMS.accdb"
but it didn't help.

Tell me what connection string i can use.

You could keep the database name (fully qualified path and file) in a settings variable like


and use the connection string

 "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Settings.DatabaseFile & "MOMS.accdb"

You'd have to prompt for the location on the first run then save that value back into the settings variable for subsequent runs.

This article has been dead for over six months. Start a new discussion instead.