I am rather new to Database developing, and I am building a simple one to track Work Hours for our small company. Now that my program is done, I need to find a way to hook the Connection String on the Database that is located in a folder within the Local Network Server.
I am building a C# application which uses a SqlConnection
.
My Database is a LocalDB, .mdf file
.
How the program works:
- Users install the program on their computers locally with the
Setup.msi
file - The program connects to the Local Server to access the Database (the drive letter depends on the PC. This is what's bugging me since I can give an absolute path)
Right now my Connection String looks something like this:
public static string ConnectionString { get; set; } = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TimeControl.mdf;Integrated Security=True;MultipleActiveResultSets=True;";
But this is no good as I was only using this during the actual programming for debugging purposes.
Is there a simple way to make it so that everyone can connect to the DB and access it, whatever their drive letter is? A relative path of some sort.
Thanks!