Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the Windows Application also sql mdf file in project bin folder and i have the two user at control panel site i try to connect from one user that time switch user and connect with another user but same time only one user can use the windows application but try to connect another user same time it will be generate error like requested login is failed


What I have tried:

I put sql mdf file at bind folder i try to connect with two clients
i also Set in Sql Like security NT AUTHORITY NETWORK SYSTEM
Posted
Updated 5-Aug-17 21:51pm

If you want multiuser access to the same database, then it is a very, very good idea to use SQL Server to manage the file and a very, very bad idea to access the .MDF file directly. You can do it using OleDb and releasing the database connection as soon as possible, but even then it generally gives horrible problems and I've never seen a good example - I have seen some horrible kludges and lash-ups though!

So connect the DB to SQL permanently, let SQL Server manage it completely, and change your app to use SqlCnnection, SqlCommand, and so forth.
 
Share this answer
 
Comments
Msufiyan Ansari 5-Aug-17 3:09am    
Thanks Sir But What is the Solution is there
OriginalGriff 5-Aug-17 3:42am    
Read what I said...
Msufiyan Ansari 6-Aug-17 3:52am    
Dear All
Now Error is Resolved I Change the Connection As Sql Server Base and Also Add the Client User in the Sql Server User then Also Apply Permission For Client User then Now it is working
Many Many Thanks All You
Thanks OriginalGriff At first time You Already Told the Solution it is Correct
OriginalGriff 6-Aug-17 4:00am    
You're welcome!
Maybe this SQL Server tutorial will be of help to you: MS SQL Server Tutorial[^]
And this C# example: How to connect SQL Database to your C# program, beginner's tutorial[^]
 
Share this answer
 
To answer your question, you can NOT use the same MDF file in multiple instances of SQL Server Express or LocalDb at the same time. Only one instance can attach the file at a time.

Use a full SQL Server if you want more than one client to connect to the database at a time.
 
Share this answer
 
Comments
Msufiyan Ansari 6-Aug-17 3:52am    
Dear All
Now Error is Resolved I Change the Connection As Sql Server Base and Also Add the Client User in the Sql Server User then Also Apply Permission For Client User then Now it is working
Many Many Thanks All You
Thanks OriginalGriff At first time You Already Told the Solution it is Correct
Dear All
Now Error is Resolved I Change the Connection As Sql Server Base and Also Add the Client User in the Sql Server User then Also Apply Permission For Client User then Now it is working
Many Many Thanks All You
Thanks OriginalGriff At first time You Already Told the Solution it is Correct
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900