all groups > sql server odbc > june 2005 >
You're in the

sql server odbc

group:

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



SQL Server ODBC connection - how to get host / port info? Charles Durrant
6/23/2005 12:00:00 AM
sql server odbc: 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.

RE: SQL Server ODBC connection - how to get host / port info? v-sguo NO[at]SPAM online.microsoft.com
6/24/2005 9:43:31 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.
Re: SQL Server ODBC connection - how to get host / port info? Charles Durrant
6/24/2005 11:21:08 AM
Thanks for the reply Sophie - I'll check out those articles. However :

[quoted text, click to view]
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.

Re: SQL Server ODBC connection - how to get host / port info? Charles Durrant
6/24/2005 11:53:05 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.

[quoted text, click to view]

Re: SQL Server ODBC connection - how to get host / port info? v-sguo NO[at]SPAM online.microsoft.com
6/27/2005 8:12:39 AM
Hello,

The odbc informaiton can be get from the following registry key

HKEY_LOCAL_MACHINE\SOFTWARE\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.
AddThis Social Bookmark Button