Home > Archive > MS SQL Server ODBC > June 2005 > SQL Server ODBC connection - how to get host / port info?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL Server ODBC connection - how to get host / port info?
Charles Durrant

2005-06-23, 11:23 am

I have a connection to SQL Server set up via SQLConnect() referencing a
System DSN. Is there a programatic way to obtain the SQL Server machine's
host name and port number from the established connection? The documentation
for SQLGetInfo and SQLGetConnectAttr doesn't seem to cover these items.

Thanks,
Charles Durrant.


Sophie Guo [MSFT]

2005-06-24, 7:23 am

Hello,

Since you can established the connection successfully, the connection
string you use include the host name. You can also refer to the following
articles:

EnumSQLSvr.exe - Enumerate SQL Servers
http://www.sqldev.net/misc/EnumSQLSvr.htm

ListSQLSvr.exe - Enumerate SQL Servers
http://www.sqldev.net/misc/ListSQLSvr.htm

Sophie Guo
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security

====================
====================
=============
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================
====================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Charles Durrant

2005-06-24, 7:23 am

Thanks for the reply Sophie - I'll check out those articles. However :

"Sophie Guo [MSFT]" <v-sguo@online.microsoft.com> wrote in message
news:0jsczEKeFHA.940@TK2MSFTNGXA01.phx.gbl...
> Hello,
> Since you can established the connection successfully, the connection
> string you use include the host name.

I'm not using a connection string - I'm using SQLConnect and just giving it
the ODBC System DSN name, user and password. I can get the SQL Server
instance name from the connection using SQLGetInfo (... SQL_SERVER_NAME
....), but I don't think this is nescesarily the same as the host name of the
machine on which the server is running.

Regards,

Charles Durrant.


Charles Durrant

2005-06-24, 7:23 am

Unfortunately both those examples only give very restricted information on
the SQL server instances - I need to get the host machine name and SQL
Server port number (for passing to a Java application for it to create a
JDBC connection).

Any other API's I should be looking at ? The Information must be somewhere
as the ODBC DSN dialogs show it.

Thanks in advance,

Charles Durrant.

"Sophie Guo [MSFT]" <v-sguo@online.microsoft.com> wrote in message
news:0jsczEKeFHA.940@TK2MSFTNGXA01.phx.gbl...
> Hello,
>
> Since you can established the connection successfully, the connection
> string you use include the host name. You can also refer to the following
> articles:
>
> EnumSQLSvr.exe - Enumerate SQL Servers
> http://www.sqldev.net/misc/EnumSQLSvr.htm
>
> ListSQLSvr.exe - Enumerate SQL Servers
> http://www.sqldev.net/misc/ListSQLSvr.htm
>
> Sophie Guo
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
>
> ====================
====================
=============
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ====================
====================
=============
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



Sophie Guo [MSFT]

2005-06-27, 3:23 am

Hello,

The odbc informaiton can be get from the following registry key

HKEY_LOCAL_MACHINE\S
OFTWARE\ODBC\ODBC.INI

The port of named instance is dynamically determined when connecting.
However, you could manually configure it on server.

Sophie Guo
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security

====================
====================
=============
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================
====================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com