Forum: Ruby How to remote connect to the SQL server 2005 when th ere is a ‘\’ in the SQL server name, such a

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Wesley C. (Guest)
on 2009-04-07 14:26
(Received via mailing list)
Hi, Guys,

How to remote connect to the SQL server 2005 when there is a ‘\’ in the
server name, such as\active?

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

On local, there is a SQL 2005 server, it is:
*Server name:*
*User:* Wesley
*Password:* 111111
I can connect it successfully by:
*'', 'Wesley', '111111')*


But on another remote server, it is SQL 2005 with the value like:
*Server name:*\thesql
*User:* Wesley
*Password:* abc?de
I can't connect it successfully by:
*'**\thesql', 'Wesley', 'abc?de')*

*'**\\thesql', 'Wesley', 'abc?de')*


I get error message:

`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*


* *

*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 ='ADODB.Connection')*



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

Wesley C..
This topic is locked and can not be replied to.