简体   繁体   English

将数据库附加到 Visual Studio 2010 的问题

[英]Problem of attaching a database to visual studio 2010

I press add connection in database explorer then put the server name which is Rabbitmasterpc我在数据库资源管理器中按添加连接,然后输入服务器名称,即 Rabbitmasterpc

windows Authentication, attach a database file: --> I browse to the database i attached.. give it a logical name..click 'ok'. windows 身份验证,附加数据库文件:-> 我浏览到我附加的数据库..给它一个逻辑名称..单击“确定”。 And what I get:我得到了什么:

"A network-related or instance specific error occured while establishing a connection to SQL Server. The server was not found or was not accessable. Verify that the instance name is correct and that SQL Server is configured to allow removte connections. (provider: Named Pipes Provider, error:40- Could not open a connection to SQL server)" “在建立与 SQL 服务器的连接时发生与网络相关或实例特定的错误。找不到服务器或无法访问该服务器。验证实例名称是否正确,并且 SQL 服务器配置为允许删除连接。(提供者:命名Pipes Provider,错误:40- 无法打开与 SQL 服务器的连接)”

UPDATE:更新:

http://www.mssqltips.com/tip.asp?tip=1673

The article says it is in facets..but i dont have it inside文章说它是多方面的..但我里面没有

Try using code below to open the connection.尝试使用下面的代码打开连接。

Try
        Dim objconnection As SqlConnection = New  _
            SqlConnection("Server=localhost;Database=DATABASENAME;" & _
                          "user ID = YOURUSERID; password = YOURPASSWORD;")

        objconnection.Open()
        objconnection.Close()

        MessageBox.Show("Database Connection Success")
Catch ex As Exception
        MessageBox.Show("Database Connection Error: " & ex.Message)
End Try

Check if SQL Server is configured (via SQL Server Configuration Manager) to accept remote connections.检查 SQL 服务器是否已配置(通过 SQL 服务器配置管理器)以接受远程连接。

Also, you may need to check the Connections property page for your database in Management Studio, as well as firewall settings: http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx此外,您可能需要在 Management Studio 中检查数据库的 Connections 属性页以及防火墙设置: http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to- enable-remote-connections-in-sql-server-2008.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM