Bonjour,
j'ai un petit soucis dans le programme suivant :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
bool Connect(SQLHANDLE *hOdbcEnv, SQLHANDLE *hDbConn)
{
	SQLRETURN sr;       //Return code for your ODBC calls
 
	//  First : Allocating ODBC Environment Handle
    sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, hOdbcEnv);
    if(sr != SQL_SUCCESS)
	{
		 displayODBCError (sr,"Error in Allocating Environment.", hOdbcEnv, SQL_HANDLE_ENV); 
		 return false;
	}
	ecrit_fichier("Allocating Environment OK.");
 
	// Second : Setting Application's ODBC Version
   sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, 0);
    if(sr != SQL_SUCCESS)
	{
		 displayODBCError (sr,"Error in Setting ODBC Version.", hOdbcEnv, SQL_HANDLE_ENV);
		 return false;
	}
	ecrit_fichier("Setting ODBC Version OK.");
 
	// Third : Allocating a Connection Handle
    sr = SQLAllocHandle(SQL_HANDLE_DBC, hOdbcEnv, hDbConn);
    if(sr != SQL_SUCCESS)
	{
		displayODBCError (sr,"Error in Allocating Connection.", hDbConn, SQL_HANDLE_DBC);
	    return false;
	}
	ecrit_fichier("Allocating Connection OK.");
}
et voila comment j'appelle la fonction :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
int _tmain(int argc, _TCHAR* argv[])
{
	//***************allocate ODBC variables*******************//
	SQLHANDLE hOdbcEnv; //ODBC Environment handle
    SQLHANDLE hDbConn;  //ODBC Connection handle
	int retour;
 
	if (Connect(&hOdbcEnv, &hDbConn))
	{
		ecrit_fichier("connecté");
	}
    Disconnect(&hOdbcEnv, &hDbConn) ;
}
et en fait dans ma fonction Connect, � la ligne :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
// Second : Setting Application's ODBC Version
   sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, 0);
j'obtiens comme retour de ma fonction : SQL_INVALID_HANDLE et je ne vois pas pourquoi.