Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to add an ADO.net EDM to my VC# win forms project generating it from a local mdf file. I choose MS SQL server database file as the data source. And I specify the file path next. Im logging on to the server using windows authentication.
The problem occurs when I click OK:

"AN attempt to attach an auto-named database for file [file path] failed. a db with the same name exists, or specified file cannot be opend, or its located on UNC share."

Any suggestions?
PS: I cant even copy the mdf file to somewhere else because its being used by another program. I dont know what program!
Posted
Updated 19-Jun-12 23:11pm
v2

1 solution

You may have actually answered your own question. If you cannot access the file due to another programming having it, then your EDM probably cannot get at it for the same reason.

But check out what the error message says and eliminate all of the other causes. Jeez, don't they teach debugging in school anymore???!!!!

First is the path to the file correct? Check for misspellings.
Then does a database with the same name already exist in the target database? If so you have to purge it...or even better ... use the fracking database instead of an MDF file!!!
Third -- is it located on your local hard drive or a network share. It must be on your local drive.
And then comes the last one which is screaming at your freaking face: or specified file cannot be opened

Now why don't you try and figure out why the file cannot be opened (which your question already has the cause in it)
 
Share this answer
 
Comments
cs101000 23-Jun-12 3:23am    
Thank u SASS_Shooter. Im new to sql server and manipulating databases and actually its mechanism is not clear to me.
The file path is correct of course. And I dont know how to check and how to purge and how to use the fracking one! The database is located on my local drive.
whats more, they teach humility instead of debugging these days ;)

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