0

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!

7
  • Can you use the ip 127.0.0.1? As in - Data Source=127.0.0.1\MSSQLLocalDB; Commented Apr 19, 2016 at 15:23
  • I thought 127.0.0.1 was a IP pointer to your local machine? I am trying to access the DB on a Local Network Server. Commented Apr 19, 2016 at 15:24
  • Why not put the file on a shared drive and just use the network path to the file? Commented Apr 19, 2016 at 15:26
  • @JoakimHansson as written Here, it says for the AttachDBFilename option: Remote server, HTTP, and UNC path names are not supported. Commented Apr 19, 2016 at 15:32
  • @Chakraa you are correct, I must have misunderstood the question, sorry about that! Commented Apr 19, 2016 at 15:34

1 Answer 1

1

The proper way to do this would be to create a SQL-Server. Namely a machine which has the purpose to provide database services. There you could create a database everybody can access.

For further information read here. Here you can get an overview on existing versions of Microsoft SQL Server.

Another solution would be to make the user install SQL-Express along with your application (see here). This would write all the data to the database on their own machine. I guess you want to avoid this.

Sign up to request clarification or add additional context in comments.

10 Comments

Our PC-Server has Windows installed and we mainly use it as a backup server / put folders and company stuff in there. Would the installation of such a program disrupt our original use of the server?
As long as you have no SQL-Server installation on it there shouldn't be any problems.
Ok I see how to perform the installation, I will get on that right away. Do you have an idea as how to write the Connection String though? A way so I can remotely connect to the DB.
@Chakraa As soon as you have the SQL-Server installed you can use "SQL Server Management Studio" to get the connection string from your database.
And is SQL Server 2008 R2 the best option or is there a newer / better server?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.