Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i use ssms connect the sqlserver database ,can show the system database, but

the other database can not open ,show the dialog mdf file is occupy by other progress ,

the database is use by other desktop application code by c# ,but i wonder why the database is occupy by other progress

What I have tried:

when i restart MSsqlserver services ,the database can open
Posted
Updated 16-Nov-20 15:14pm
Comments
RedDk 17-Nov-20 12:57pm    
Short answer:
For SSMS(E) to recognize anything, and I'm assuming you're refering to databases in the Browser panel, the INSTANCE has to be running and that can be accomplished by going into Services and Applications under Computer Management/Services ... and checking whether the STATUS of INSTANCE(NAME) is "Running".

But I suspect you've no idea what you're doing with the backend of an app you've created using C# in VS or you've downloaded a C# example of database programming from which you intend to learn how to connect to a database through C# but only have a downloaded .MDF file.
q889711 19-Nov-20 4:49am    
the app develop by other people so i donot have souce code

1 solution

You should never access MDF files that are being used by SQL Server directly: always go via SQL Server. That's the whole idea!
SQL Server is a multiuser database server that stores data in MDF files - but it should be the only system changing them or the multiuser part of the system starts to break down.
 
Share this answer
 
Comments
q889711 17-Nov-20 1:53am    
i never access mdf files ,i access database but not open the database ,why? i had never been encounter this situation ,if i access database is ok,when i run the other application,i can not access database。 two application not access database simultaneously?
OriginalGriff 17-Nov-20 2:23am    
How is your app connecting to the DB, and how did you use SSMS to access it?
q889711 19-Nov-20 4:53am    
i don't have app source code, the app is develop by c# is the c/s app and the web page embed in local iis,so i find the sqlserver connectstring in webconfig file but why when the app is running ,i can't open database through the ssms
OriginalGriff 19-Nov-20 5:48am    
If you don't have the app source code, there isn't anything you can do: the app has opened the DB file directly for exclusive access and the system will not let two systems do that at the same time.

Go back to the people you got the app from, and either get the source from them or explain why you need this. Only they can help you here - we can't.
q889711 20-Nov-20 2:25am    
i find the result the app connect database use ./sqlexpress but i connect database use . so i can't open the database ,when i connect database use ./sqlexpress i can open the database

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