Unix Technical Forum

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

This is a discussion on SQL Server ODBC connection - how to get host / port info? within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> I have a connection to SQL Server set up via SQLConnect() referencing a System DSN. Is there a programatic ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 09:46 PM
Charles Durrant
 
Posts: n/a
Default SQL Server ODBC connection - how to get host / port info?

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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 09:46 PM
Sophie Guo [MSFT]
 
Posts: n/a
Default RE: SQL Server ODBC connection - how to get host / port info?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 09:46 PM
Charles Durrant
 
Posts: n/a
Default Re: SQL Server ODBC connection - how to get host / port info?

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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 09:46 PM
Charles Durrant
 
Posts: n/a
Default Re: SQL Server ODBC connection - how to get host / port info?

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.
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 09:47 PM
Sophie Guo [MSFT]
 
Posts: n/a
Default Re: SQL Server ODBC connection - how to get host / port info?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com