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