Visual Studio 2010 抱怨数据库版本

发布于 2024-11-05 19:40:35 字数 1490 浏览 10 评论 0原文

又是美好的一天。

好吧,我想做的是将数据库保留在 App_Data 文件夹中以便于使用,现在我认为这很容易:将数据库复制到文件夹中并更改连接字符串。但是当我尝试时,我收到了可怕的版本错误:

数据库 'C:\用户\GUÐMUNDUR\桌面\测试\测试\APP_DATA\IRIS2.MDF' 打不开,因为是版本 661.此服务器支持版本655及更早版本。降级路径不是 支持。无法打开新数据库 'C:\USERS\GUÐMUNDUR\DESKTOP\TEST\TEST\APP_DATA\IRIS2.MDF'。 创建数据库被中止。一次尝试 附加一个自动命名的数据库 文件 C:\Users\Guðmundur\Desktop\Test\Test\App_Data\IRIS2.mdf 失败的。同名数据库 存在,或者指定的文件不存在 打开,或者位于 UNC 共享上。

现在我想知道是否有人可以提出解决方案,我可以通过 SQL 脚本重新创建数据库,所以这没有问题,并且那里没有重要的(尚未)信息。

有什么想法吗?

下面是连接字符串:

  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|IRIS2.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

我使用的解决方案

我进入 SQL Server Management Studio 并将数据库附加到那里,同时将其保留在 App_Data 文件夹中。然后我进入 Visual Studio,创建一个新的数据连接,创建后我单击它并进入它的“属性”选项卡,从连接字符串中选择所有内容,并用它替换我原来的内容。

所以连接字符串现在看起来像这样:

  <connectionStrings>
    <add name="ApplicationServices"
          connectionString="Data Source=WODAN;Initial Catalog=IRIS;Integrated Security=True"
          providerName="System.Data.SqlClient" />
  </connectionStrings>

以下是附件过程的说明(由 Ladislav Mrnka 提供) msdn.microsoft.com/en-us/library/ms190209.aspx

感谢大家的投入,特别感谢 Ladislav 帮助我完成任务。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

瑕疵 2024-11-12 19:40:35

这意味着您的 .mdf 文件是由较新版本的 SQL Server 创建的。 661 应该是 SQL Server 2008 R2,并且您可能只使用 SQL Server 2008(这是可以作为 Visual Studio 2010 安装的一部分进行安装的版本)。

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).

碍人泪离人颜 2024-11-12 19:40:35

版本 655 是 SQL 2008。661 是 2008 R2。该盒子不知道如何处理较新的版本。

Version 655 is SQL 2008. 661 is 2008 R2. The box doesn't know how to handle the newer version.

著墨染雨君画夕 2024-11-12 19:40:35

在“添加连接”对话框中,单击“高级...”按钮。找到数据源属性并确保下拉列表与您正在使用的实例匹配。

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.

嘿哥们儿 2024-11-12 19:40:35

晚点跳。这是我发现的。

用户的系统上可能同时安装了 2008 和 2008 R2。但如果您看到无法打开 661 版本的错误,请将您的 SQL Server Express 更新到 2008 R2。它将解决这个问题。

只要您使用的是 SQL Server Express 版本,就可以直接在 Visual Studio 中打开 MDF 文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文