如何从一个SQL Server数据库的数据 [英] How to retrieve data from a SQL Server db

查看:150
本文介绍了如何从一个SQL Server数据库的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写在VBA一个code片段来从SQL Server 2008 R2数据库中提取数据。不过,我得到一个错误的Conn.Open: [微软] [SQL Server本机客户端10.0]命名管道提供商:无法打开到SQL Server的连接[53]

I'm writing a code snippet in VBA to pull data from a SQL Server 2008r2 database. However, I'm getting a error at Conn.Open: [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53].

使用 ConnectionString.com 和其他的SO问题,我写的:

Using ConnectionString.com and another SO Question, I've written this:

Function GetAddress() As String
    Dim Conn As ADODB.Connection
    Set Conn = New ADODB.Connection
    Dim Rst As ADODB.Recordset
    Set Rst = New ADODB.Recordset

    Conn.ConnectionString = "Provider=SQLNCLI10;Server=12.34.5678;" & _
                            "Database=OurDB;User ID=myuserid;Password=mypw;"
    Conn.Open

    Set Rst.ActiveConnection = Conn
    Rst.Open "Select top 1000 * from MainTable"
End Function

<一个href="http://www.dbforums.com/microsoft-sql-server/1659580-named-pipes-provider-could-not-open-connection-sql-server.html"相对=nofollow>谷歌搜索错误建议,命名管道可能被禁用。继铅,我检查了SQL Server配置管理器和命名管道都相当有效(后面的共享内存和TCP / IP三阶)。

Googling the error suggested that the Named Pipes might be Disabled. Following that lead, I checked the SQL Server Configuration Manager and Named Pipes are quite Enabled (3rd order behind Shared Memory and TCP/IP).

如何让我这个错误会消失吗?我使用正确的连接字符串?

How do I make this error go away? Am I using the right connection string?

推荐答案

仔细检查这部分连接字符串的:

Double-check this part of your connection string:

Server=12.34.5678

它看起来像由一个IP地址指的是服务器,但它不是一个IP地址。

It looks like referring to the server by an IP address, but it's not an IP address.

这篇关于如何从一个SQL Server数据库的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆