Home > Archive > MS SQL Server ODBC > October 2006 > SQLBrowseConnect and Trusted_Connection=yes, Bug?









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 SQLBrowseConnect and Trusted_Connection=yes, Bug?
Scott Willeke

2006-10-24, 6:40 pm

I am trying to use SQLBrowseConnect to obtain a list of databases on the
server with Trusted_Connection=y
es in the connect strings. I am unable to get
it working. I can get it working when not using trusted connection. I found
lots of other people complaining about this on the net, but nobody seems to
have found a solution.
The connection string I'm using is:
"DRIVER={SQL Server};SERVER=(loca
l);Trusted_Connectio
n=yes"

The output string from SqlBrowseConnect is:
"SERVER:Server=& #123;(local),FESTER}
;UID:Login
ID=?;PWD:Password=?;*APP:AppName=?;*WSID:WorkStation ID=?"

The SQL_RESULT code is SQL_NEED_DATA, and the error message returned from
SQLGetDiagRec is "[Microsoft][ODBC SQL Server Driver]Invalid connection
string attribute".

Again this works fine if I specify a user via UID and PWD, but fails with
Trusted_Connection. I have verified the database supports
trusted_connections,
and I'm using SQL Server 2005.


Does anyone know what I might be missing?

Scott Willeke

2006-10-24, 6:40 pm

Note the following code seems to work okay. I'd still like to know if there
is a known problem with SQLBrowseConnect though...

/// <summary>
/// SQLBrowseConnect seems to fail with trusted_connection=y
es, so I've this
method hacks around it to get a database list.
/// </summary>
private static string[] GetDatabaseListTrust
edConnectHack(string
serverName)
{
ArrayList names = new ArrayList();

using (OdbcConnection cnn = new OdbcConnection("DRIVER={SQL
Server};SERVER=" + serverName + " ;DATABASE=master;Tru
sted_Connection=yes"))
{
cnn.Open();

IDbCommand cmd = cnn.CreateCommand();
cmd.CommandText = "SELECT name FROM sys.databases";

using (IDataReader reader = cmd.ExecuteReader())
{
while(reader.Read())
{
names.Add(reader[0]);
}
}
}
return (string[])names.ToArray(typeof (string));
}



"Scott Willeke" wrote:

> I am trying to use SQLBrowseConnect to obtain a list of databases on the
> server with Trusted_Connection=y
es in the connect strings. I am unable to get
> it working. I can get it working when not using trusted connection. I found
> lots of other people complaining about this on the net, but nobody seems to
> have found a solution.
> The connection string I'm using is:
> "DRIVER={SQL Server};SERVER=(loca
l);Trusted_Connectio
n=yes"
>
> The output string from SqlBrowseConnect is:
> "SERVER:Server=& #123;(local),FESTER}
;UID:Login
> ID=?;PWD:Password=?;*APP:AppName=?;*WSID:WorkStation ID=?"
>
> The SQL_RESULT code is SQL_NEED_DATA, and the error message returned from
> SQLGetDiagRec is "[Microsoft][ODBC SQL Server Driver]Invalid connection
> string attribute".
>
> Again this works fine if I specify a user via UID and PWD, but fails with
> Trusted_Connection. I have verified the database supports
> trusted_connections,
and I'm using SQL Server 2005.
>
>
> Does anyone know what I might be missing?
>

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