PDA

Click to See Complete Forum and Search --> : path for database in connection string


steve_rm
Dec 2nd, 2004, 09:31 AM
Hello,

I have a database application in my connection string l have the following.

OleDbConnection cnnTeacher = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Library\LibrarySystem.mdb;Persist Security Info=False");

But if want to install this program on another machine l don't want to have to change every connection string. Is there an easy way to do this.

The database is in the same folder that the solution is in.

Thanks in advance,

Steve

Mike Hildner
Dec 2nd, 2004, 10:44 AM
Two ideas come to mind, probably others as well. One, if you're sure it's in the same place as the executable, you can use Application.StartupPath (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsApplicationClassStartupPathTopic.asp) or for more flexibility, stick it in the .config file and grab it through code with the ConfigurationSettings (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemconfigurationconfigurationsettingsclasstopic.asp) class.