CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Location
    Parkersburg, WV
    Posts
    3

    Get computer name of current ODBC connection

    Does anyone know how to determine the computer name of the current ODBC connection.

    For instance, I am connecting over a WAN to an ODBC Data Source via ADO. I want to know the computer name of the machine that I am connecting to. The user can change to DSN to connect to different machines, and I want to be able to determine the computer name of each machine.

    If I was able to determine SQL Servers in a network on a 95/98 machine that would work too.

    Thanks


    James Kline
    Simonton Windows, Inc.

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Get computer name of current ODBC connection

    there is a NetServerEnum API that you can use to find all SQLServers (use SV_TYPE_SQLSERVER
    flag) in your LAN.
    I haven't tested this in W95/W98.

    also, you can find the Servername from TSQL:
    select @@servername


  3. #3
    Join Date
    Nov 1999
    Location
    Parkersburg, WV
    Posts
    3

    Re: Get computer name of current ODBC connection

    The NetServerEnum API does not work with 95/98 machines from the information that I have gathered, but the select @@servername should work fine.

    Thanks

    James Kline
    Simonton Windows, Inc.

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Get computer name of current ODBC connection

    you might also want to try the following approach.
    after calling the open method of the connection object the connectionstring property of the connection object contains the connectionstring after resolving all details.
    It contains an Address= field, that contains the server name in my tests.

    Dim cn as new ADODB.Connection
    cn.Open "dsn=t0010;uid=xx;pwd=xx;database=xxx"



    after calling cn.open, cn.Connectionstring contained "...Address=servername..."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured