The database cannot be opened because it is version 782. This server supports version 706 and earlier. A downgrade path is not supported
Asked Answered
L

6

85

I have created a sample database using SQL Server 2014 Express and added it to my Windows Form solution. When double click on it to open I get this error.

The database cannot be opened because it is version 782. This server supports version 706 and earlier. A downgrade path is not supported

I am using Visual Studio 2013. I really don't understand that I am using the two latest versions of Microsoft products and they are incompatible. Am I missing something? How can I open this database?

enter image description here

Labionasal answered 13/10, 2014 at 18:36 Comment(4)
You need to point Visual Studio at your SQL Server 2014 instance. It's not that the two are incompatible, it's that Visual Studio is using its 2012 instance by default, and it doesn't support databases from 2014. The reason it uses 2012 as its default: SQL Server 2014 didn't exist when Visual Studio 2013 was released.Inanity
@AaronBertrand thanks. How can I point VS at my SQL Server 2014. Is there any link that will guide?Labionasal
Sure, just stop pointing Visual Studio (and your application) at a file (using AttachDBFileName). Assuming the database is already attached at your local .\SQLEXPRESS instance, just change the connection strings to point to that server (Data Source=.\SQLEXPRESS;Initial Catalog=OMERDENEME;...) and stop using AttachDBFileName.Inanity
Related: The database 'xxx' cannot be opened because it is version 904, Trying to attach a database fails because it is version 782Despoliation
R
142

Try changing Tools > Options > Database Tools > Data Connections > SQL Server Instance Name.

The default for VS2013 is (LocalDB)\v11.0.

Changing to (LocalDB)\MSSQLLocalDB, for example, seems to work - no more version 782 error.

Rosecan answered 1/12, 2014 at 1:35 Comment(9)
I had similar issues with Visual Studio 2013 Express for Web and Entity Framework 6. EF created the MDF file automatically, but I couldn't connect from VS when using (LocalDB)\v11.0. Changing the server name to (LocalDB)\MSSQLLocalDB made that error about version #'s go away.Applegate
I also had to change the connection string in the web.config file to (LocalDB)\MSSQLLocalDBDrumhead
In VS Studio 2015, the default is (LocalDB)\MSSQLLocalDB. So, this does not help in this caseProlix
I had to restart Visual Studio after changing above mentioned settingPeriosteum
@Kun-yaoWang, above comment mentioned by usefulBee worked for me and I am using VS 2015.Periosteum
After following above step, it require to restart VS.Carrot
@Manoj, how on earth does a comment stating that the answer doesn't help, work for you? Anyway, Aaron Bertrand's comments on the question worked for me and I am also using VS 2015.Patton
After changing the Connection string from (LocalDB)\v11.0 to (LocalDB)\MSSQLLocalDB this solution works...Dilan
Restarting VS after modifying the options is very important in this caseEuh
M
9

Try to change the compatibility level, worked for me.

Verify what level it is

USE VJ_DATABASE;
GO
SELECT compatibility_level
FROM sys.databases WHERE name = 'VJ_DATABASE';
GO

Then make it compatible with the older version

ALTER DATABASE VJ_DATABASE
SET COMPATIBILITY_LEVEL = 110;   
GO
  • 100 = Sql Server 2008
  • 110 = Sql Server 2012
  • 120 = Sql Server 2014

By default, Sql Server 2014 will change the db versions compatibility to only 2014, using the @@ version you should be able to tell, which version Sql Server is.

Then run the command above to change it the version you have.

Additional step: Ensure you look at the accessibility of the DB is not reset, do this by right clicking on properties of the folder and the database. (make sure you have rights so you don't get an access denied)

Middlebuster answered 13/10, 2014 at 21:59 Comment(1)
Compatibility level (for forwards compatibility) and database version (for backwards compatibility) have nothing to do with each other. A database created on a newer version is not usable on an older version, irrespective of compatibility level. This does not solve the issue.Connive
W
2

For me using solution provided by codedom did not worked. Here we can only changed compatibility version of exiting database.

But actual problem lies that, internal database version which do not matches due to changes in there storage format.

Check out more details about SQL Server version and their internal db version & Db compatibility level here So it would be good if you create your database using SQL Server 2012 Express version or below. Or start using Visual Studio 2015 Preview.

Weaken answered 27/11, 2014 at 8:44 Comment(0)
R
2

This solution solve my problem: (from: https://msdn.microsoft.com/en-us/library/ms239722.aspx)

To permanently attach a database file (.mdf) from the Data Connections node

  1. Open the shortcut menu for Data Connections and choose Add New Connection.

    The Add Connection dialog box appears.

  2. Choose the Change button.

    The Change Data Source dialog box appears.

  3. Select Microsoft SQL Server and choose the OK button.

    The Add Connection dialog box reappears, with Microsoft SQL Server (SqlClient) displayed in the Data source text box.

  4. In the Server Name box, type or browse to the path to the local instance of SQL Server. You can type the following:

    • "." for the default instance on your computer.
    • "(LocalDB)\v11.0" for the default instance of SQL Server Express LocalDB.
    • ".\SQLEXPRESS" for the default instance of SQL Server Express.

    For information about SQL Server Express LocalDB and SQL Server Express, see Local Data Overview.

  5. Select either Use Windows Authentication or Use SQL Server Authentication.

  6. Choose Attach a database file, Browse, and open an existing .mdf file.

  7. Choose the OK button.

    The new database appears in Server Explorer. It will remain connected to SQL Server until you explicitly detach it.

Ruggiero answered 21/5, 2017 at 9:47 Comment(1)
This solution worked for me. I changed my Vs2012 default connection setting in tool-option-database tools->data connection--> sql server name =(LocalDB)\MSSQLLocalDB. and then followed the above step. and at step 4 i entered ny sql 2014 instance name as (LocalDB)\MSSQLLocalDB. and every thing is fine. thanks bro.Accentor
C
1

Another solution is to migrate the database to e.g 2012 when you "export" the DB from e.g. Sql Server manager 2014. This is done in menu Tasks-> generate scripts when right-click on DB. Just follow this instruction:

https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/

It generates an scripts with everything and then in your SQL server manager e.g. 2012 run the script as specified in the instruction. I have performed the test with success.

Consistent answered 16/11, 2016 at 10:4 Comment(0)
S
0

I use VS 2017. By default SQL Server Instance name is (LocalDB)\MSSQLLocalDB. However, downgrading the compatibility level of the database to 110 as in @user3390927's answer, I could attach the database file in VS, choosing Server Name as "localhost\SQLExpress".

Sakmar answered 29/5, 2019 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.