1,105,225 Community Members

Access Connection String

Member Avatar
Newbie Poster
1 post since Mar 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

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.

Member Avatar
Reverend Jim
Noli mentula
5,394 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]

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 three months: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: