C.Fasolin
C.Fasolin

Reputation: 319

How to connect to SQL Server in C++

I'm trying to connect to SQL Server 2008 with ODBC driver, I have searched around but didn't find much. Also, I tried the source at Using ODBC to connect to SQL SERVER 2008 but I received this message:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I'm using this connection string:

DRIVER={Sql Client};
SERVER=WIN-QNPAH3SE4CK\SQLSRV,1433;
DATABASE=dummy;
UID=sa;
PWD=sasasasa;
Trusted_Connection=no;

Can anyone help me?

Upvotes: 3

Views: 16496

Answers (1)

João Augusto
João Augusto

Reputation: 2305

In your connection string replace the {SQL Client} with {SQL Server}

Edit: That's why it's always important to post the code...

You can't do this cast: (SQLWCHAR*)"DRIVER={SQL Server};SERVER=WIN-QNPAH3SE4CK\SQLSRV,1433;DATABASE=dummy;UID=sa;PWD=sasasasa;Trusted_Connection=no;"

Switch it to something like this: (SQLWCHAR*)TEXT("DRIVER={SQL Server};SERVER=WIN-QNPAH3SE4CK\SQLSRV,1433;DATABASE=dummy;UID=sa;PWD=sasasasa;Trusted_Connection=no;")

Upvotes: 5

Related Questions