Problem with SQL FETCH
-
Hi, I have some problem with this query i execute under visual C++6.0
"SELECT Nom, CodePostal, Sum(Montant) AS MontantRemb, DateTraitement FROM TClient GROUP BY Nom, CodePostal, Montant,DateTraitement HAVING (((DateTraitement)=#09/05/2002#));"
In Microsoft Access interface it work well but if i execute it via ODBC like this :retcode = SQLExecDirect(m_hstmt,(SQLCHAR*)strSQL, SQL_NTS);
this isntruction work also but i have a problem with SQL Fetch:while (( retcode = SQLFetch(m_hstmt))!= SQL_NO_DATA) { SQLGetData(m_hstmt, 1, SQL_C_CHAR, szNomClient, 25, &cbName); SQLGetData(m_hstmt, 2, SQL_C_CHAR, szCodePostal, 6, &cbName); SQLGetData(m_hstmt, 3, SQL_C_CHAR, szMontant, 16, &cbName); SQLGetData(m_hstmt, 4, SQL_C_CHAR, szDateTraitement, 11, &cbName); }
Here retcode return 100 and i can't obtain my data Thanks in advance for any help -
Hi, I have some problem with this query i execute under visual C++6.0
"SELECT Nom, CodePostal, Sum(Montant) AS MontantRemb, DateTraitement FROM TClient GROUP BY Nom, CodePostal, Montant,DateTraitement HAVING (((DateTraitement)=#09/05/2002#));"
In Microsoft Access interface it work well but if i execute it via ODBC like this :retcode = SQLExecDirect(m_hstmt,(SQLCHAR*)strSQL, SQL_NTS);
this isntruction work also but i have a problem with SQL Fetch:while (( retcode = SQLFetch(m_hstmt))!= SQL_NO_DATA) { SQLGetData(m_hstmt, 1, SQL_C_CHAR, szNomClient, 25, &cbName); SQLGetData(m_hstmt, 2, SQL_C_CHAR, szCodePostal, 6, &cbName); SQLGetData(m_hstmt, 3, SQL_C_CHAR, szMontant, 16, &cbName); SQLGetData(m_hstmt, 4, SQL_C_CHAR, szDateTraitement, 11, &cbName); }
Here retcode return 100 and i can't obtain my data Thanks in advance for any helpAre you sure your datatypes in the calls to SQLGetData() are correct? Your select statement has column #3 as Sum(Montant). Without knowing your table structure, I'm guessing Montant is a numeric field, in which case you'll want to use something like SQL_C_ULONG with a size of 4 bytes. Your date field, the 4th column, would also have a problem. That should go with SQL_C_TYPE_TIMESTAMP, assuming it's stored as a date field in your table and not a string. SQL_C_CHAR is only used for character (string) columns.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein