http://www.developpez.biz/downloads/c/vc/sources/ADOlib.zip int main() { SQLRETURN rc; SQLHENV henv; SQLHDBC hdbc1; SQLHSTMT hstmt1; char CodeLivre[7]; long CCodeLivre; char Titre[51]; long CTitre; char NumSection[5]; long CNumSection; int Choix; char* MonDSN=new char[20]; // allocation du handle d'environnement et définition de la version rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0); strcpy(MonDSN,"Bibli Access"); // allocation du handle de connexion et connexion rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1); rc = SQLConnect(hdbc1, (unsigned char*)MonDSN, SQL_NTS, (unsigned char*) "bibli", SQL_NTS, (unsigned char*)"bibli", SQL_NTS); // allocation du handle de statement rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt1); // Bind Parametre rc= SQLBindParameter(hstmt1, 1, SQL_PARAM_INPUT, SQL_C_CHAR,SQL_CHAR, 4, 0, NumSection, 5, &CNumSection); CNumSection = SQL_NTS; // choix de la section printf("Choix de la section :"); fflush(stdin); gets(NumSection); // envoi de la requête de comptage rc = SQLExecDirect(hstmt1,(unsigned char*)"SELECT code_livre, titre FROM Livre WHERE code_section= ? ORDER BY Titre", SQL_NTS); // attache à une variable C rc = SQLBindCol(hstmt1, 1, SQL_C_CHAR, CodeLivre, 7, &CCodeLivre); rc = SQLBindCol(hstmt1, 2, SQL_C_CHAR, Titre, 51, &CTitre); // récupération du résultat rc = SQLFetch(hstmt1); // affichage du résultat while(rc ==0) { printf("Livre : %s , %s\n", CodeLivre, Titre); rc=SQLFetch(hstmt1); } fflush(stdin); getchar(); // fermeture du curseur SQLCloseCursor(hstmt1); // libération des handles et déconnexion SQLFreeHandle(SQL_HANDLE_STMT, hstmt1); SQLDisconnect(hdbc1); SQLFreeHandle(SQL_HANDLE_DBC, hdbc1); SQLFreeHandle(SQL_HANDLE_ENV, henv); return 0; }