Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with SQL FETCH

Problem with SQL FETCH

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cheickna
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • C Cheickna

      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

      T Offline
      T Offline
      TyMatthews
      wrote on last edited by
      #2

      Are 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups