Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQLBrowseConnect and Trusted Connection

Author  Topic 

HIL
Starting Member

1 Post

Posted - 2004-08-05 : 03:47:39
Hello,

I used the SQLBrowseConnect function to get first the SQL Server instance of a server and a second time to get database list from one instance of SQL Server.

To do it, I wrote:

SQLHENV henv = NULL;
SQLHDBC hdbc = NULL;


#define MAX_CONN_OUT 1024
SQLCHAR szInConn[MAX_CONN_OUT];
SQLCHAR szOutConn[MAX_CONN_OUT];
SQLSMALLINT cbOutConn;
SQLRETURN retcode;

// Initialize the ODBC environment.
SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv)

// This is an ODBC v3 application
SQLSetEnvAttr (henv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3, SQL_IS_INTEGER);

// Allocate a connection handle
SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc)

SQLBrowseConnect(hdbc, (SQLCHAR*)"DRIVER={SQL Server}", SQL_NTS, szOutConn, MAX_CONN_OUT, &cbOutConn);

/* Here I get names of instances of SQL Server */

SQLBrowseConnect(hdbc, (SQLCHAR*)"SERVER=(local);Trusted_Connection=Yes", SQL_NTS, szOutConn, MAX_CONN_OUT, &cbOutConn);

/* Here I should get list of databases for one instance */

The first call to SQLBrowseConnect works, il gives me the different instances of SQL Server running. But the second does'nt work, and a call to SQLGetDiagRec tells me "[Microsoft][ODBC SQL Server Driver]Invalid connection string attribute" because of the parameter "Trusted_Connection=Yes".

So, does someone know how it is possible to perform a SQLBrowseConnect in trusted connection mode ?

Thanks to answer me.

Hilaire Verschuere

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-08-05 : 14:07:38
What is SQLBrowseConnect?

Tara
Go to Top of Page

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2004-08-05 : 16:42:00
SQLBrowseConnect() is an ODBC API tool that returns information about either one SQL Server, or all of the SQL Servers in a domain. The server list is derived from the same source used by the SQL-DMO NameList container, although more parameters are available.

-PatP
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-08-05 : 16:53:06
Your kidding....

Can this be done with tsql?



Brett

8-)
Go to Top of Page
   

- Advertisement -