Discussion Locked

Connect to SQL Server

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to connect to SQL 7.0 on a remote machine(machine name: HQ_RAS, Server Name: HQ_RAS) using VB/AD0. Here are the connection parameters:

cn.Provider = "SQLOLEDB"
cn.Properties("Data Source")= "\\HQ_RAS\HQ_RAS"
cn.Open

I created a Global group named SQLAccess with 2 members on our PDC, then created a local group on HQ_RAS with the SQLAccess group as a member. I added the local group as a login on the SQL Server and added the login to all of the fixed server roles and to the db_owner fixed database role for the database that I intend to access. I also gave all possible permissions for that database. When cn.Open runs I recieve the following message:

Run-time error'-2147467259 (80004005)':
[DBNMPNTW]ConnectionOpen (CreateFile())

I am not using ASP or a Web Server, but these are sited in all of the documentation on this error message that I have been able to find.

Thanks!

3 replies

by andrew

It looks like you have a couple of problems:

DBNMPNTW is the Named Pipes library, which won't work for a remote machine. You need to use TCP/IP which is DBMSSOCN. Use the SQL Client Network Utility to set the default network library to TCP/IP. Ifyou dont have that installed on the client machine (where your ADO calls are made), use this registry script:

REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer\Client\ConnectTo]
"DSQUERY" = "DBMSSOCN"

Another problem may be the data source. I don't think you need to specify machine name and server name. Try this code:

Dim oCon as ADODB.Connection
Set oCon = New ADODB.Connection
oCon.Open "Provider=SQLOLEDB.1;Password=;User ID=sa;Initial Catalog=db_name;Data Source=HQ_RAS"

Just replace the db_name with the name of the database you're accessing, and the sa user to whomever you like.

Hope this helps.

This discussion is closed to new replies.