问题
Good day once more.
Okay so what I want to do is to keep my database in the App_Data folder for ease of use, now I thought this would be easy: Copy the database into the folder and change the connection string. But when I try that I get the horrible version error:
The database 'C:\USERS\GUÐMUNDUR\DESKTOP\TEST\TEST\APP_DATA\IRIS2.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported. Could not open new database 'C:\USERS\GUÐMUNDUR\DESKTOP\TEST\TEST\APP_DATA\IRIS2.MDF'. CREATE DATABASE is aborted. An attempt to attach an auto-named database for file C:\Users\Guðmundur\Desktop\Test\Test\App_Data\IRIS2.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Now I was wondering if anyone can suggest a solution to this, I can recreate the database via the SQL script so there is no problem with that and there is no important (yet) information there.
Any ideas?
Here is the connection string:
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|IRIS2.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
The solution I used
I went into the SQL Server Management Studio and attached the database there while keeping it in the App_Data folder. Than I went into Visual Studio, created a new Data Connection and after it was created I clicked on it and went into Properties tab for it and selected everything from the Connection String and replaced what I originally had with it.
So the connection string looks like this now:
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=WODAN;Initial Catalog=IRIS;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Here are the instructions for the attachment process (as supplied by Ladislav Mrnka) msdn.microsoft.com/en-us/library/ms190209.aspx
Thanks to everyone for their input and special thanks for Ladislav for helping me through out.
回答1:
It means that your .mdf file was created by newer version of SQL Server. 661 should be SQL Server 2008 R2 and you are probably using only SQL Server 2008 (that is the version you can install as part of Visual Studio 2010 installation).
回答2:
Version 655 is SQL 2008. 661 is 2008 R2. The box doesn't know how to handle the newer version.
回答3:
In the Add Connection dialog, click on the Advanced.. button. Find the Data Source property and make sure the drop down matches the instance you're using.
回答4:
Jumping in Late. Here is what I found.
One might have both 2008 and 2008 R2 Installed on their system. But if you see the error saying it cannot open 661 version, then update your SQL Server Express to 2008 R2. It will fix the issue.
MDF files can be opened directly in your visual studio as long as your are using express edition of SQL server.
来源:https://stackoverflow.com/questions/5922043/visual-studio-2010-complains-about-database-versions