Cannot open Database version 957

G C 0 Reputation points
2024-11-18T09:36:15.2+00:00

I am new to Visual Studio 2022 Community and probably my question has already been answered.

This is the Problem:

I have a laptop "A" with Windows 10 + Visual Studio Community 2022 +SQL Server 2019 LocalDB +SQL Server 2022 Localdb.

I have created a new VB Form project (<myproject>) on "A". It is located in Kroof C:\Users<myname>\Koofr<myproject>\DB.mdf. The DB.mdf is located in project rooth. By using the proper connection string which points to DB.mdf in the project rooth the DB opens properly in VB debug window and the project works correctly.

I have a second Laptop "B" with Windows 11 + Visual Studio Community 2022 +SQL Server 2022 Localdb. This machine is syncronized on Kroof cloud with the same credentials as machine "A" and so "B" "sees" the same project as the one in "A".

When I try to open <myproject> in "B" and try to connect to DB.mdf through New Data Origin I get Error "Cannot open file DB.mdf because it is version 957.This server can accept only db version 904 or earlier".

Suggestions gathered from the web suggest to install in "B" a newer version of LocalDB, but the latest version is the already installed (SQL Server 2022 Localdb) . From the web also I get that db version 957 can be handled by 2022 Localdb.

Why this strange behaviour? What to do to correct it? (The same problem exists using OneDrive instead of Kroof).

By the way I had in the past the same problem ("the DB cannot be opened because is version.....etc") on machine "A" in spite of having the then latest Localdb installed. I solved the problem by a complete fresh installation of Windows 10 + fresh installation of latest Local DB + fresh installation of latest Visual studio. After that the problem disappeared. I would like to avoid a fresh installation of Windows 11 on machine "B"., if possible.

Is it possible that VisualStudio has also a Localdb included in it? If yes what Locadb version is included in Visual Studio 2022? And is it used during debug of <myproject>only or also during "myproject.exe" run time?

Thanks

Developer technologies Visual Studio Other
SQL Server Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2024-11-18T11:50:38.3233333+00:00

    +SQL Server 2019 LocalDB +SQL Server 2022 Localdb. Cannot open file DB.mdf because it is version 957

    You can not attach a database from a newer SQL Server version to an older on e= 2019; databases are not backward compatible.

    0 comments No comments

  2. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2024-11-18T22:37:10.1033333+00:00

    Suggestions gathered from the web suggest to install in "B" a newer version of LocalDB, but the latest version is the already installed (SQL Server 2022 Localdb) .

    But apparently that is not what you are connecting to. The error message makes it clear that you are connecting to an instance of SQL 2019.

    Is it possible that VisualStudio has also a Localdb included in it? If yes what Locadb version is included in Visual Studio 2022? And is it used during debug of <myproject>only or also during "myproject.exe" run time?

    Yes, you get a localdb with Visual Studio 2022. Which version? Well, since VS 2022 was released before SQL 2022, my bets are that it is SQL 2019. Then again, they have been cranking out point versions like crazy to VS 2022, and maybe some later versions have been refreshed.

    In any case, use the command sqllocaldb info to see which localdb instances you have. Then you can connect to with SSMS and see which version each of them have. Make sure that you use the SQL 2022 instance of localdb in Visual Studio. (Somewhere you are setting up the connection string, I guess.)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.