Problems wirh SQLConnect and SQLDriverConnect

Problems wirh SQLConnect and SQLDriverConnect

Post by jeff don » Fri, 08 Nov 2002 08:55:29



Hi,

I'm using C++ and I can't get SQLDriverConnect to work with this
connection string:

Provider=SQLOLEDB.1;Persist Security Info=True;Initial
Catalog=TheDatabase;Data Source=127.0.0.1;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation
ID=WIN2K;Use Encryption for Data=False;Tag with column collation when
possible=False;User Id=theUsername;PASSWORD=myPass;

The error is 'Data source name not found and no default driver
specified'

However, this string does work:

DRIVER=SQL Server;DATABASE=TheDatabase;SERVER=127.0.0.1;UID=theUsername;PWD=myPass;

Neither works with SQLConnect; the error is 'Invalid string or buffer
length'.  SQLConnect only seems to like DSN Names, but not connection
strings.

This is the code snipet:

strcpy((char *)buf, "theUsername");
strcpy((char *)buf2, "mypass");

if (SQL_SUCCEEDED(iDBRC)) iDBRC = SQLDriverConnect( hDBConn, NULL,
(unsigned char *)lpszConnectionString, SQL_NTS, buf, 2048, &len,
SQL_DRIVER_NOPROMPT);
//if (SQL_SUCCEEDED(iDBRC)) iDBRC = SQLConnect(hDBConn, (unsigned char
*)lpszConnectionString, SQL_NTS, buf, SQL_NTS, buf2, SQL_NTS);

Anyone have a clue how to make a connection to SQL Server using that
first connection string?

Changing connection strings isn't really an option.  Obviously, I
could parse the first string and create one in the form of the second,
but I would rather not.  I'm thinking there must be a better way.

I should probably also mention the first string does work when used
with an ADODB.Connection object.

Thanks,
Jeff

 
 
 

Problems wirh SQLConnect and SQLDriverConnect

Post by Igor Shekale » Fri, 08 Nov 2002 17:11:12


Hello jeff,

No way. ODBC is not a wrapper for OLEDB at all :-)
You can't use OLEDB provider when You work with ODBC.

OLEDB can use ODBC for come cases, but ODBC can't use OLEDB.

 jd> Anyone have a clue how to make a connection to SQL Server using that
 jd> first connection string?

 jd> Changing connection strings isn't really an option.  Obviously, I
 jd> could parse the first string and create one in the form of the
 jd> second, but I would rather not.  I'm thinking there must be a better
 jd> way.

 jd> I should probably also mention the first string does work when used
 jd> with an ADODB.Connection object.

 jd> Thanks,
 jd> Jeff

Igor Shekalev, manager
     http://www.sqledit.com, SQL editor with ODBC support

 
 
 

1. Problem wirh ODBC and SQL SERVER 6.5

Hi All World!

I have a problem with any Clients, with a client server information system.

I have a network, with 20 front ends(VB40 - 32 bits that use ODBC), and
MS-SQL Server 6.5,
I haven't problem,
but , i now have problems with any clients(three).

Some times, appear an error message about ODBC driver, I reinstall newly,
the driver and the problem is ended, but I'm tired of that, and other times,
the client, just work slowly, and this generate me problems
In NT Visor, appear the follow error mesages:
*****
mesg : 1704 warnig open objects parameters may be too low

identificador : 17055

mesg : 17425 attempt was made to free up descriptors in localdes()

identificador : 17055

mesg : 174262 Run sp_configure to increase parameters value.
*****
I have configured SQL Server to 32 users, with 20 users i had problems, what
parameters must increase? , What parameters i shoud change?,
What I can do?, Somebody help me?...

Thanks a lot.

Danny Leonardo Martinez Murcia

2. Help with pics in data base in VB5.0EE

3. JNet direct driver problem wirh prepared sql stmt

4. Date Display Format

5. help - problems wirh isgdata ado data cntrol

6. 10 digit cd code required

7. Problem Wirh Dynamic SQL.

8. DALLAS -- Delphi Software Developers

9. SQLDriverConnect and "locales.dat" problem

10. SQLDriverConnect function problems from Visual Basic

11. ODBC SQLConnect problem

12. Cli sqlconnect problem