none
Two SQL Servers. I've attached my database to the newer one. But don't know how to connect from within VS 2019, RRS feed

  • Question

  • I have MSSQL Server 2017 (free edition) and because of issues with old copy of VS, I also downloaded the 2012 version though I may have actually used an older version of SQL when I built my website. So now I am using Visual Studio 2019 and it changed all my old projects so that they are now 2019 version. Now from within Visual Studio server explorer area , I have red box on my database. When I click the refresh button, it throws this error:

    The database 'C:\MYWEBSITENAME NEW COPY\APP_DATA\USADB.MDF' cannot be opened because it is version 869. This server supports version 852 and earlier. A downgrade path is not supported.
    Could not open new database 'C:\MYWEBSITENAME NEW COPY\APP_DATA\USADB.MDF'. CREATE DATABASE is aborted.
    An attempt to attach an auto-named database for file C:\MYWEBSITENAME new copy\App_Data\USADB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

    When I right click on the database red x it gives option to modify connection. Then when that box opens I see there are several choices in drop down box:

       think I'm supposed to click one of these:

    Microsoft SQL Server (SqlClient) or

    Microsoft SQL Server Database File (SqlClient)

    But I'm not sure which to click and depending on which one I click, I'm supposed to do things which I don't know how to do.

    I have another local copy version of this website that did eventually connect with the database but I don't know how it happened. When I open SQL server Management System, it opens that database in my visual studio folder and seems to be connected. It lets me open the tables, etc.  I just can't seem to get Visual Studio to accept the connection and I don't know how to modify the connection.  I'm at my wits end. Needing to get my website back on line and working correctly.



    • Edited by RaekC Monday, June 10, 2019 5:14 PM
    Monday, June 10, 2019 5:12 PM

All replies

  • Hi RaekC,

     

    >>The database 'C:\MYWEBSITENAME NEW COPY\APP_DATA\USADB.MDF' cannot be opened because it is version 869. This server supports version 852 and earlier. A downgrade path is not supported.

    Could not open new database 'C:\MYWEBSITENAME NEW COPY\APP_DATA\USADB.MDF'. CREATE DATABASE is aborted.

     

     You get the .MDF file from the higher version of SQL Server. And now you are using a lower version of SQL Server. You cannot attach/detach or backup/restore a database from a newer version of SQL Server down to an older version.

     

    Would you please install the same SQL Server as your mdf file version? The commands given on stack overflow will create another db with the version installed on your computer. For more details, please refer to https://www.c-sharpcorner.com/forums/how-to-rectify-cannot-be-opened-because-it-is-version-852 and http://sqlserverbuilds.blogspot.com/2014/01/sql-server-internal-database-versions.html

     

    Hope this could help you .

    Best regards,

    Dedmon Dai


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, June 11, 2019 6:29 AM
  • Hello. Thank you.

    Do you have the link for Stack overflow that explains how to do this?

    (I still don't understand why it worked on one copy of my same project. Both were created with same versions, one was just a copy for debugging. So I don't understand that. Does having two copies with same database name create a problem?)

    Tuesday, June 11, 2019 12:25 PM
  • I tried the delete/create method but it did not resolve problem. I followed:

    in the command prompts at this directory["C:\Program Files\Microsoft SQL Server\130\LocalDB\Binn"] Command "SqlLocalDB.exe delete "MSSQLLocalDB"" , This will delete the older version. Command "SqlLocalDB.exe create "MSSQLLocalDB" , this will create the newer version.

    But it still will not attach.

    Tuesday, June 11, 2019 1:33 PM
  • I finally got it to attach:

    When I right click on my database in the Server window, I then clicked modify the connection. Then when SQL box Opened, I browsed to my file folder where that database is and in the SQL connection property box, it had MSSQL Server (or something similar) and below that in drop down were other versions.. So I clicked my newest version and then tested and it succeeded. It then replaced my original database name (MYDBA) TO lower case name (mydba).

    Also, although it is in my Server explorer window, when I tried to attach in my SQL Server Mgt. Studio, I get an error that it is being used. Is that normal? I thought you could open in both at same time.

    Is it OK to publish the site now since it is connected to a version of SQL ? Do I have to worry about the version of SQL my host has?


    • Edited by RaekC Tuesday, June 11, 2019 8:27 PM
    Tuesday, June 11, 2019 7:56 PM
  • It is best to upgrade to the same version as the sql server where you get the mdf file.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, June 14, 2019 9:32 AM