SQLRETURN SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSMALLINT NameLength1, SQLCHAR *UserName, SQLSMALLINT NameLength2, SQLCHAR *Authentication, SQLSMALLINT NameLength3);
Le résultat est SQL_SUCCESS en cas de succès.
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
static SQLHANDLE hConnexion;
...
if (SQLConnect(hConnexion, "nt_sqlserver", SQL_NTS, "scott", SQL_NTS, "tiger", SQL_NTS)!=SQL_SUCCESS)
{
...
}
...
if (SQLDisconnect(hConnexion)!=SQL_SUCCESS)
{
...
}
...