2

If I copy an .mdf file created by SQL server management studio and put it in the app_data folder I get this error:

"This database file is not compatible with the current instance of SQL Server.

To resolve this issue, you must upgrade the database file by creating a new data connection, or you must modify the existing connection to this database file.

For more information, see http://go.microsoft.com/fwlink/?LinkId=235986"

And if I attempt to Add connection using the visual studio wizard, choosing the Microsoft SQL server database file and select the file I get this error:

" Unable to open physical file "path" {access is denied) an attempt to attach an auto named for file "path" a database with the same name exists, or specified file cannot be opened, or it is located on UNC share"

And if I attempt to add a connection choosing the "Microsoft SQL server" option in the choose data source window:

"a network related or instance specific error occurred while establishing a connection to SQL server. the server was not found or was not accessible. Verify the the instance name is correct and that the SQL is configured to allow remote connections..."

The only reason I want to connect visual studio to the database is because VS doesn't allow me to import text files. I have imported a text file into a DB from SQL server management studio and I want to connect it to VS. I've turned off UAC in windows 7 and I have file permissions to the mdf file.

4
  • Visual Studio is not a language, it is a development environment used to program in several languages. If you have questions about doing something in that language, ask about that language (C#, VB.net, C++, etc.). All of the languages supported in Visual Studio will allow you to "import a text file". Perhaps if you asked about what it is you're trying to do exactly, instead of fighting with SQL Server when you don't need it, someone can help you. Commented Nov 14, 2012 at 22:48
  • 1
    Hi Ken White, I didn't say it was a language and I didn't ask for help in any language. I probably wasn't clear - VS has a server explorer and I wanted to connect to another database using a wizard in the explorer. I've got it to work after a hours of crying though. Thanks for your help. Commented Nov 14, 2012 at 23:01
  • 1
    don't you like to share the answer with us? Commented Jan 31, 2014 at 7:06
  • Would be nice to share, I just hit the same issue. Commented Feb 10, 2015 at 20:37

1 Answer 1

1

Old question, but just to provide an answer for visitors from Google, the problem is not related to file system access (although Administrator accounts should have full privileges to the folder containing the mdf and log files). The solution is that SQL Management Studio needs to be opened using "Run As Administrator". The elevated permissions will allow SQL Server (or SQLExpress) to attach the older mdf file and update it. Once the db is attached, you can access it in Visual Studio by adding a database connection through the Add New Item->Data->ADO.NET Entity Data Model wizard.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.