问题
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:
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.
来源:https://stackoverflow.com/questions/19843631/multiple-connections-to-an-mdf-file