Bonsoir,
je me connecte à une base de donnée MySQL par l'intermédiaire ODBC sous VC++. La connexion est bien établie mais aucune requête ne passe
résultat du SQLRETURN après la connexion 0 ok
résultat du SQLRETURN après une requête -2

voila le code :
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <sqlext.h>
using namespace std;
 
#define LEN 15
 
 
void main()
{
	SQLHENV henv;
	SQLHDBC hdbc;
	SQLHSTMT hstmt;
	SQLRETURN retcode;
 
	SQLINTEGER szID;
	SQLFLOAT szAmp, szCyc;
	SQLLEN IDLen, AmpLen, CycLen;
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
	retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
	retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
	retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
 
	retcode = SQLConnect(hdbc, (SQLCHAR*) "MyDB", SQL_NTS, (SQLCHAR*) "root", 
		SQL_NTS, (SQLCHAR*) "admin", SQL_NTS);
 
 
 
	retcode=SQLExecDirect(hstmt,(SQLCHAR*) "SELECT * FROM variable" ,SQL_NTS);
	cout<<retcode<<endl;
 
 
 
	if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
 
                  // Bind columns 1, 2, and 3
		retcode = SQLBindCol(hstmt, 1, SQL_C_NUMERIC, &szID, sizeof(SQLINTEGER), &IDLen);
		retcode = SQLBindCol(hstmt, 2, SQL_C_FLOAT, &szAmp, sizeof(SQLFLOAT), &AmpLen);
		retcode = SQLBindCol(hstmt, 3, SQL_C_FLOAT, &szCyc, sizeof(SQLFLOAT), &CycLen); 
 
                  // Fetch and print each row of data. On an error, display a message and exit.
                  for (int i ; ; i++) {
                     retcode = SQLFetch(hstmt);
                     if (retcode == SQL_ERROR || retcode == SQL_SUCCESS_WITH_INFO)
                        cout<<"error";
                     if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
                        wprintf(L"%d: %S %S %S\n", i + 1, szID, szAmp, szCyc);
                     else
                        break;
                  }
               }
}
quelqu'un peut m'expliquer qu'est ce que ce passe ? merci d'avance