Friday, February 24, 2012

[HELP!] How do you make the database path relative in the connection string?

Hi everyone,

I am working on a Hospital Information System project with a team of 6.Each one of us builds or modifies a part of the system and shares the project over a common repository. The problem here is that we use the absolute path of the database in our connection string. Although the directory structure of our project is the same for each member, since the main project folder itself is stored in different locations on each person's computer (for example, one may have it stored in c:\My Documents and the other in d:\ My Documents), we are forced to modify the connection string manually each time someone else from the team updates the repository with the database. How do we make the path of the database relative so that we don't have to modify the connection string manually each time after receiving an update from the repository?

Your help is greatly appreciated.

If you're referencing the path, then I wonder what database you are using. e.g. for MSSQL you would refer to a server and the database on that server, generally just '.' for a local server

Lot's of ways you could do this, e.g. I've just been playing with clickonce install and this is one I use;

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbRaptor_Data.mdf;Integrated Security=True;User Instance=True"

No comments:

Post a Comment