3

I have a database in my App_Data folder that was created using SQL Server 2008 R2.

When I try to view a page, I get this error message:

The database 'C:\My Projects\NCPA\APP_DATA\NCPA.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:\My Projects\NCPA\APP_DATA\NCPA.MDF'. CREATE DATABASE is aborted.

An attempt to attach an auto-named database for file C:\My Projects\NCPA\APP_DATA\NCPA.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Here's my connection string:

<add name="NCPA" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NCPA.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />

I have SQL Server 2008 R2 and Visual Studio 2010 installed on my computer. I've searched this problem all over, and everything says "You need R2", but I already have it.

I've also seen that I need to check the SQL Server instance name by going to Tools > Options > Database Tools > Data Connections, mine just says SQLEXPRESS. Is that right? Should it be something else?

What do I need to do here? Is there something that I might not have installed? Is there a setting in Visual Studio that I need to change? I feel like every solution I've found is so vague, or the solution is something I've already done.

EDIT: Here's what I have if I start up SQL Server, and go to Help > About:

Microsoft SQL Server Management Studio - 10.50.1617.0

Microsoft Analysis Services Client Tools - 10.50.1617.0

Microsoft Data Access Components (MDAC) - 6.1.7600.16385

Microsoft MSXML - 3.0 4.0 6.0

Microsoft Internet Explorer - 9.0.8112.16421

Microsoft .NET Framework - 2.0.50727.4961

Operating System - 6.1.7600

Steven
  • 18,761
  • 70
  • 194
  • 296
  • your configurations is correct, and i dont think theres a problem with the DB file, the problem is in the SQL server which has an older version than the one created by your DB. – raym0nd Jul 21 '11 at 20:33
  • possible duplicate of [.mdf is too new (661) my database supports version 655](http://stackoverflow.com/questions/2462919/mdf-is-too-new-661-my-database-supports-version-655) – Gabe Jul 21 '11 at 20:35
  • Not inclined to vote to close as duplicate, as this OP has stated that he has already installed R2. OP in linked question hadn't done anything of the sort prior to asking. – Adam Maras Jul 21 '11 at 20:49

6 Answers6

6

While you may have installed SQL Server 2008 R2, are you sure you upgraded the instance you're using to R2?

Use the SQL Server Installation Center from your R2 media and the "Upgrade from SQL Server 2000, SQL Server 2005, or SQL Server 2008" option to upgrade your SQLEXPRESS instance to R2.

Adam Maras
  • 26,269
  • 6
  • 65
  • 91
  • That sounds like that might be the problem...I've already installed SQL Server 2008 R2, is there a way to upgrade the instance after the installation? – Steven Jul 21 '11 at 20:42
  • 1
    Indeed. As per my post, use the SQL Server 2008 R2 installer to do so. Instead of installing a new instance, choose the option to upgrade an existing one. – Adam Maras Jul 21 '11 at 20:44
  • Okay, that's a step forward. But I went to the Installation Center and clicked the `Upgrade` installation, and a dialog popped up asking me to `Browse for SQL Server 2008 R2 Installation Media`. I'm not sure what file I should be looking for, I installed this a while ago. – Steven Jul 21 '11 at 20:53
  • Run the Installation Center from whatever media you got SQL Server 2008 R2 from; if it's a CD, pop the CD in and autorun it. If you downloaded it from the internet, run the `.exe` file you downloaded again. (You can redownload it if necessary.) – Adam Maras Jul 21 '11 at 21:02
1

I encountered the similar issue, when trying to attache an .mdf files that was created on another machine running SQL Server 2008 R2 Express, to the SQL Server 2008 R2 Express on my machine..

I did install 2008 (non-R2) and then 2008 R2 on my machine.

After spending hours googling to find a solution, eventually unsuccessful, I simply decided to download the installer SQLEXPR_x64_ENU.exe from here and run it again, hoping it would solve (Windows 7 64 bit)

On the installation Wizard under Installation, I selected Upgrade from SQL Server 2000, SQL Server 2005 or SQL Server 2008 and continued to press Next until it disappeared (Obviously you will have to wait until it finish processiong each step).

That's it. I was able to attach the same file..

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
  • @Bishan *Please* do not use code formatting to just highlight things; it should *only* be used for actual code. The way you have highlighted all these product names makes things harder to read! – Andrew Barber Mar 03 '13 at 12:37
1

Are you really, really sure that the SQL Server you are trying to attach the database to is SQL Server 2008 R2?

Your error message says that your SQL Server only supports version 655, and everything I found concerning these version numbers said that version 655 is SQL Server 2008 (non-R2):

If you really have SQL Server 2008 R2 and it still doesn't work, you'll probably have to re-install the server, like raym0nd said in the comment to his answer.


EDIT:
Steven, none of the numbers you posted is the "real" version number of your SQL Server.
You can find out the actual version number by running select @@version in a query window in Management Studio.
On my machine, Help --> About says Microsoft SQL Server Management Studio - 10.50.1617.0 like on your machine, but when I run select @@version I get this:

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)   Mar 29 2009 10:11:52
  Copyright (c) 1988-2008 Microsoft Corporation  Express Edition (64-bit) 
  on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) 

And here comes the weird part:
I am 100% sure that I installed SQL Server 2008 R2 on my machine.
In fact, the SQL Server stuff in my start menu says "SQL Server 2008 R2" everywhere, and the Help --> About window that you mentioned has a huge SQL Server 2008 R2 logo as well.

But according to several lists that I just found, 10.0.2531.0 is SQL Server 2008 SP1.
So my installation seems somehow messed up as well.
Strange, very strange...

Community
  • 1
  • 1
Christian Specht
  • 35,843
  • 15
  • 128
  • 182
  • I'm pretty sure. I edited my original post to include the component name and version information. Take a look and see if you see anything weird. – Steven Jul 21 '11 at 20:39
  • I'm seeing something weird on **my** machine - see above, I edited my answer as well! – Christian Specht Jul 21 '11 at 21:38
1

My guess is that your code is trying to connect to the database instance that was install with Visual Studio 2010 instead of the SQL Server 2008 R2 instance that you have installed.

Gabe
  • 84,912
  • 12
  • 139
  • 238
  • Okay. So what can I do to change that? Is there a way to tell which one my code is connecting to? – Steven Jul 21 '11 at 20:44
  • The part of your connect string that says `Data Source=.\SQLEXPRESS` is telling it to use the one that came with VS2010. If you execute `select @@ServerName` in Management Studio it should tell you what instance name to use. – Gabe Jul 21 '11 at 20:59
0

Here what worked for me without trying any updates!

  1. From Visual Studio --> Server Explorer --> Add New Connection
  2. Change the data source to Microsoft SQL server
  3. Server name : My computer's name or localhost
  4. At the drop down list choose the database you want

Everything works fine! No updates and no 661 problems!

Perception
  • 79,279
  • 19
  • 185
  • 195
Dev_dio
  • 21
  • 3
0

Download and reinstall the new MS R2 SQL SERVER , When Microsoft updates something, it doenst support older versions most of the time.

raym0nd
  • 3,172
  • 7
  • 36
  • 73
  • 1
    He said that he already have R2 installed. Are you suggesting that he should reinstall? – Pierre-Alain Vigeant Jul 21 '11 at 20:23
  • I had the same problem couple of months ago, I had R2 installed, but still didnt work, then I downloaded a fresh copy of SQL server and re installed, restarted my computer and it worked fine. – raym0nd Jul 21 '11 at 20:25
  • @raym0nd - there has to be an easier way than reinstalling SQL Server entirely. – Steven Jul 21 '11 at 20:26