# How to remote connect to the SQL server 2005 when th ere is a â€˜\\â€™ in the SQL server name, such a

**URL:** <https://www.ruby-forum.com/t/how-to-remote-connect-to-the-sql-server-2005-when-th-ere-is-a-a-a-in-the-sql-server-name-such-a/164921>\
**Category:** Ruby\
**Created:** [April 7, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/how-to-remote-connect-to-the-sql-server-2005-when-th-ere-is-a-a-a-in-the-sql-server-name-such-a/164921 "2009-04-07T12:26:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenpassion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@chenpassion](https://www.ruby-forum.com/u/chenpassion)\
**Post date:** [April 7, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/how-to-remote-connect-to-the-sql-server-2005-when-th-ere-is-a-a-a-in-the-sql-server-name-such-a/164921/1 "2009-04-07T12:26:54Z")

</div>

Hi, Guys,

How to remote connect to the SQL server 2005 when there is a â€˜\â€™ in the  
SQL  
server name, such as 192.168.0.11\active?

In fact, when I try to remote connect it by the SQL 2005 client,  
everything  
goes well.

On local, there is a SQL 2005 server, it is:  
_Server name:_ 192.168.132.157  
_User:_ Wesley  
_Password:_ 111111  
I can connect it successfully by:  
_db=SqlServer.new(‘192.168.132.157’, ‘Wesley’, ‘111111’)_

_db.open(â€˜active\_localâ€™)_

But on another remote server, it is SQL 2005 with the value like:  
_Server name:_ 192.168.0.11\thesql  
_User:_ Wesley  
_Password:_ abc?de  
I can’t connect it successfully by:  
_db=SqlServer.new(‘192.168.0.11\thesql’, ‘Wesley’, ‘abc?de’)_

_db.open(‘active\_int’)_  
or  
_db=SqlServer.new(‘192.168.0.11\thesql’, ‘Wesley’, ‘abc?de’)_

_db.open(‘active\_int’)_

I get error message:

E:/NetbeansProjects/ActiveTrainer/lib/sql-server.rb:_26_:in  
`method\_missing’: Open (WIN32OLERuntimeError)

```
OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server

 * [dbmssocn] **General network error. Check your network

```

documentation. \*

```
HRESULT error code:0x80020009

  Exception occurred. from

```

E:/NetbeansProjects/ActiveTrainer/lib/sql-server.rb:26:in `open’

```
    from E:/NetbeansProjects/ActiveTrainer/lib/sql-server.rb:76

```

The \*26 \*above points to the sentence below in Red color.

My connect string is:

_def initialize(host, username = ‘sa’, password=’’)_

- 

```
@connection = nil*

```

- 

```
@data = nil*

```

- 

```
    @host = host*

```

- 

```
    @username = username*

```

- 

```
    @password = password*

```

_end_

- 
  - 

_def open(database)_

- 
# Open ADO connection to the SQL Server database\*
- connection\_string = “Provider=SQLOLEDB.1;”\*

- connection\_string \<\< “Persist Security Info=False;”\*

- connection\_string \<\< “User ID=#{@username};”\*

- connection\_string \<\< “password=#{@password};”\*

- connection\_string \<\< “Initial Catalog=#{database};”\*

- connection\_string \<\< “Data Source=#{@host};”\*

- connection\_string \<\< “Network Library=dbmssocn”\*

- \*_@connection = WIN32OLE.new(‘ADODB.Connection’)_

_End_

\*\*

I connect the remote SQL server by SQL 2005 client, using the username  
and  
password above, I succeed.  
Appreciated to any suggestions.

Thanks.  
Wesley C…
