ODBC, SqlGetData
-
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?
-
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?
Try use SQLBindCol and SQLFetch. Pavel Sonork 100.15206
-
Try use SQLBindCol and SQLFetch. Pavel Sonork 100.15206