0

当我使用 Visual Studio 2012 打开 Visual Studio 2010 解决方案时,我收到以下消息:

SQL Server Express 和 LocalDB

在 Web.config 文件中,我更改了连接字符串

从:

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename
=|DataDirectory|\databaseName.mdf;Integrated Security=True;User Instance=True"

到:

connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename
=|DataDirectory|\databaseName.mdf;Integrated Security=True"

我无法连接数据库,当我运行应用程序时,我仍然收到一条错误消息:

An attempt to attach an auto-named database for file (FILE) failed. 
A database with the same name exists, or specified file cannot be opened, 
or it is located on UNC share.

The attempt to attach to the database failed with the following information: 
Failed to generate a user instance of SQL Server due to a failure in starting 
the process for the user instance. The connection will be closed.
4

2 回答 2

0

只需双击您项目的解决方案。并自动转换项目。

于 2013-07-26T09:53:45.027 回答
0

我已经能够连接到我的数据库,但我仍然收到一条错误消息。

  • 在服务器资源管理器(视图 > 服务器资源管理器)中单击连接到数据库按钮。
  • 数据源:Microsoft SQL Server (SqlClient)
  • 服务器名称:(LocalDB)\v11.0
  • 附加数据库文件:mdf 文件的路径
  • 测试连接
  • OK(如果测试连接成功)

在所有这些步骤之后,我在服务器资源管理器中的数据库图标上出现了绿色图标。

现在您可以右键单击数据库并选择属性,然后选择连接字符串并将其粘贴到 Webconfig 文件中。

当我在 Default.aspx 文件上按 F5 时,我仍然收到错误消息:

Sql exception was unhandled by user code

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

我在文件 CategoriesBLL.cs 的行中收到错误消息

return Adapter.GetCategories();
于 2013-07-28T21:57:49.880 回答