Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
how to fixed the under error :

" Unable To open physical file : " c:\x\a.mdf".operating system error 32:32(error not found")". an attemp to attach auto-named database for file c:\x\a.mdf failed. A database with same name exists, or the specified file cannot be opened,or it is in located on UNC Share"


my sqlconnection as :
C#
using (SqlConnection con = new SqlConnection(u.connectstr))
               {
sqlcommand cmmd = new sqlcommand (x,con)
...
}


one of solution that I use for solve above error, copy project file to the another folder. but It is bad and incorrect !!!???
Posted
Updated 17-Dec-14 5:28am
v2
Comments
DamithSL 17-Dec-14 11:26am    
given code there is nothing related to given path, can you update the question with related code sample?

1 solution

Yes. Check the file: the chances are that the SQL system is on a different computer, and the file is on your PC. The remote server can't access files on you computer directly for security reasons.

Try creating the database directly in SQL, so that it is stored in the "normal" SQL Server data directory and it should work when you connect to it.
 
Share this answer
 
Comments
bernova 17-Dec-14 11:33am    
OK.Could you explain more please?
OriginalGriff 17-Dec-14 12:00pm    
Explain which bit?
bernova 17-Dec-14 12:45pm    
This line : Try creating the database directly in SQL, so that it is stored in the "normal" SQL Server data directory.

Exactly what should I do please?

thank you.


OriginalGriff 17-Dec-14 12:53pm    
Use SSMS, or see here if you want to do it in code: http://msdn.microsoft.com/en-us/library/ms176061.aspx
bernova 17-Dec-14 13:19pm    
Your purpose that is Create all of Database in Dynamically using CREATE DATABASE command and run in Storedprocedure And Don't Create Database And All of Table in wizard SQl Management Studio. Is it correct?

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