Skip to main content

Sql Native Client 10.1 [best] -

hr = pDBC->Initialize(); // use connection... pDBC->Release(); CoUninitialize(); return 0; #include <windows.h> #include <sql.h> #include <sqlext.h> #include <iostream> int main() SQLHENV henv; SQLHDBC hdbc; SQLRETURN ret;

Driver=SQL Server Native Client 10.0;Server=myServer\instance;Database=myDB;Trusted_Connection=yes;

Provider=SQLNCLI10;Server=myServer\instance;Database=myDB;Trusted_Connection=yes; sql native client 10.1

// Set connection properties (simplified) DBPROP InitProps[2]; // ... set server, db, auth ...

Provider=SQLNCLI10;Server=myServer;Database=myDB;Uid=myUser;Pwd=myPass; hr = pDBC-&gt;Initialize(); // use connection

// Connection string SQLWCHAR connStr[] = L"Driver=SQL Server Native Client 10.0;" L"Server=localhost;Database=master;Trusted_Connection=yes;"; ret = SQLDriverConnectW(hdbc, NULL, connStr, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE);

Provider=SQLNCLI10;Server=tcp:myServer,1433;Database=myDB;Trusted_Connection=yes; hr = pDBC-&gt

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);