multiple connections to an mdf file

2019-05-26 00:13发布

im creating a .Net application using c# for a university project and need some help!

I have a mdf file hosted on a network drive and need several clients to be able to access this database from their applications. Each client machine will be running their own instance of sql express.

I can access file from my application, but when another client tries to they receive the following error message

Cannot open user default database. Login failed. Login failed for user 'EEEC\40023753'.

The database state is configured to allow multiple users

The Connection String I am currently using is :

"Data Source=.\SQLEXPRESS;AttachDbFilename=\\servxxx.eeecs.qub.ac.uk\Virtual_Directories\level3\cs8\App_Data\cs4_database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

Any comments would be greatly appreciated!

1条回答
Animai°情兽
2楼-- · 2019-05-26 00:53

You need to host the database server on the network server. Several client can connect to the SQL Server Service. But several clients cannot simultaneously connect directly to the mdf file.

The file alone cannot handle concurrency. You can have multiple connection to a database server. The database software is what handles the concurrency.

查看更多
登录 后发表回答