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. ODBC, SqlGetData

ODBC, SqlGetData

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
3 Posts 2 Posters 7 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.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello I've got a listview that I fill with information about mp3's. The SQL query looks like this: SELECT * FROM mp3_info LEFT JOIN mp3_genre USING (genre_id) WHERE artist like 'a%' ORDER BY artist, album, title The query returns about 5 columns and about 200 rows. Then I use the following loop to populate the listview: do { rs.GetFieldValue(1, nMp3Id); rs.GetFieldValue(2, szName, 40); nIndex = ctl.InsertItem(ctl.GetItemCount(), szName, -1); ctl.SetItemData(nIndex, (DWORD_PTR)nMp3Id); for (int i = 3; i < m_nColumnCount; i++) { rs.GetFieldValue(i, szName, 40); ctl.SetItemText(nIndex, i-2, szName); } } while (rs.MoveNext()); The problem is that the loop is slow, It takes over 1 second to fill the listview. The GetFieldValue function looks like this: bool CODBCRecordset::GetFieldValue(int nField, char *szData, int nMaxLen) { //we are 1 based. if (!nField) return false; SQLRETURN ret; ret = SQLGetData(m_hStmt, (SQLUSMALLINT)nField, SQL_C_CHAR, szData, nMaxLen, NULL); return ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO; } Why do it take such a long time to populate the list?

    P 1 Reply Last reply
    0
    • J justin223

      Hello I've got a listview that I fill with information about mp3's. The SQL query looks like this: SELECT * FROM mp3_info LEFT JOIN mp3_genre USING (genre_id) WHERE artist like 'a%' ORDER BY artist, album, title The query returns about 5 columns and about 200 rows. Then I use the following loop to populate the listview: do { rs.GetFieldValue(1, nMp3Id); rs.GetFieldValue(2, szName, 40); nIndex = ctl.InsertItem(ctl.GetItemCount(), szName, -1); ctl.SetItemData(nIndex, (DWORD_PTR)nMp3Id); for (int i = 3; i < m_nColumnCount; i++) { rs.GetFieldValue(i, szName, 40); ctl.SetItemText(nIndex, i-2, szName); } } while (rs.MoveNext()); The problem is that the loop is slow, It takes over 1 second to fill the listview. The GetFieldValue function looks like this: bool CODBCRecordset::GetFieldValue(int nField, char *szData, int nMaxLen) { //we are 1 based. if (!nField) return false; SQLRETURN ret; ret = SQLGetData(m_hStmt, (SQLUSMALLINT)nField, SQL_C_CHAR, szData, nMaxLen, NULL); return ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO; } Why do it take such a long time to populate the list?

      P Offline
      P Offline
      Pavel Klocek
      wrote on last edited by
      #2

      Try use SQLBindCol and SQLFetch. Pavel Sonork 100.15206

      J 1 Reply Last reply
      0
      • P Pavel Klocek

        Try use SQLBindCol and SQLFetch. Pavel Sonork 100.15206

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        why? Is it faster? why are SqlGetData slow?

        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