A RalphXML >ss
bool CstockeDB::ConnectDataBase(){
if (!strlen((char *)session_id)) return false;
retcode2 = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv2);
if (retcode2!=SQL_SUCCESS && retcode2!=SQL_SUCCESS_WITH_INFO){
ssCloseConnection();
ssfprintf(fd,"1 - SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv2); n'a pas marché, renvoyant "%d"
",retcode2);
ssreturn false;
}
retcode2 = SQLSetEnvAttr(henv2, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
if (retcode2!=SQL_SUCCESS && retcode2!=SQL_SUCCESS_WITH_INFO){
ssCloseConnection();
ssfprintf(fd,"2 - SQLSetEnvAttr(henv2, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); n'a pas marché, renvoyant "%d"
",retcode2);
ssreturn false;
}
retcode2 = SQLAllocHandle(SQL_HANDLE_DBC, henv2, &hdbc2);
if (retcode2!=SQL_SUCCESS && retcode2!=SQL_SUCCESS_WITH_INFO){
ssCloseConnection();
ssfprintf(fd,"3 - SQLAllocHandle(SQL_HANDLE_DBC, henv2, &hdbc2); n'a pas marché, renvoyant "%d"
",retcode2);
ssreturn false;
}
retcode2 = SQLConnect(hdbc2,dsn, SQL_NTS,(SQLCHAR*) "sa", SQL_NTS,(SQLCHAR*) "caron73", SQL_NTS);
if (retcode2 != SQL_SUCCESS && retcode2 != SQL_SUCCESS_WITH_INFO){
ssCloseConnection();
ssfprintf(fd,"4 - SQLConnect(hdbc2,dsn, SQL_NTS,(SQLCHAR*) "sa", SQL_NTS,(SQLCHAR*) "caron73", SQL_NTS); n'a pas marché, renvoyant "%d"
",retcode2);
ssreturn false;
}
retcode2 = SQLAllocHandle(SQL_HANDLE_STMT, hdbc2, &hstmt2);ss
if (retcode2 == SQL_SUCCESS || retcode2 == SQL_SUCCESS_WITH_INFO){
ssconnected=true;
ssreturn true;
}
else{
ssCloseConnection();
ssfprintf(fd,"5 - SQLAllocHandle(SQL_HANDLE_STMT, hdbc2, &hstmt2); n'a pas marché, renvoyant "%d"
",retcode2);
ssreturn false;
}
}
Les membres privés sont :
char message[NB_MESS][1000];
SQLHDBC hdbc2;
SQLHENV henv2;
SQLRETURNssretcode2;
SQLHSTMT hstmt2;
unsigned char strsql2[1024]/*,table1[512],table2[512]*/,chaine[65535],dsn[512],session_id[14];
ss
bool connected,dja;
FILE *fd;
SQLCHAR user[256],pass[256];