0

i am developing an app where i am having a common sql server database .mdf put on a LAN Server which is needed to be connected to two or more different instances of a same application as other stations.

i am able to select the database but it is giving me and error posted below: enter image description here

how to overcome this? the connection string is

connectionString = @"Data Source =(LocalDB)\MSSQLLocalDB; AttachDbFilename = " + path + "; Integrated Security = True; Connect Timeout = 30";

P.S. it is working when a single instance is connected to it and it is preventing the second or third app to use it.

any help will be appreciated.

3
  • 2
    Possible duplicate of multiple connections to an mdf file Commented Jun 12, 2017 at 7:35
  • You are working with .mdf file not with database Commented Jun 12, 2017 at 7:50
  • 1
    Applications connect to the database, not the other way round. SQL Server isn't Access. LocalDB is a local embedded database, powered by SQL Server Express. Just use Express itself if you want multiple clients to connect Commented Jun 12, 2017 at 9:16

1 Answer 1

2

You need to host the database on a network server. Several clients can connect to a SQL Server. But several clients cannot simultaneously connect directly to an MDF file.

The file alone cannot handle the concurrency. You need to have an application for it. That's where SQL Server comes into play.

After hosting, you need to change your connection string as well. Then it should work.

connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True"
Sign up to request clarification or add additional context in comments.

Comments

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.