MFC (database) please help !
-
how can i load from my database data to my CListCtrl fast ?because now i must wait up to 10 min to load the data ! i now (WM_TIMER and virtual list that is not a solution for me because i have all the code rady ! must be something ... this is the code : the FillList4 is loaded in my oninit dialog ! void CMyList::FillList4() { CNote *pNote = new CNote(); pNote->Open(); CString sNrInregistrare; if (pNote->GetRecordCount()) pNote->MoveFirst(); int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; } pNote->Close(); } ! Remember that : i have 4 CListCtrl to load with data 1 table have ~1000 and ~1500 data Please help me because i don t have any ideea at all ! Thanks !!!!! :)
Bravoone
-
how can i load from my database data to my CListCtrl fast ?because now i must wait up to 10 min to load the data ! i now (WM_TIMER and virtual list that is not a solution for me because i have all the code rady ! must be something ... this is the code : the FillList4 is loaded in my oninit dialog ! void CMyList::FillList4() { CNote *pNote = new CNote(); pNote->Open(); CString sNrInregistrare; if (pNote->GetRecordCount()) pNote->MoveFirst(); int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; } pNote->Close(); } ! Remember that : i have 4 CListCtrl to load with data 1 table have ~1000 and ~1500 data Please help me because i don t have any ideea at all ! Thanks !!!!! :)
Bravoone
It looks really weird. What is the hardware configuration of the machine where it took 10 minutes to load this 1000 or 1500 records? Comment out the data access code and insert the same number of hard coded strings in a loop into the ListCtrls. Check what the time for this is. If it takes less time, then we can confirm that the issue is with db access, may be indexing is missing. Try this and see what the result is. cheers..Milton KB
-
It looks really weird. What is the hardware configuration of the machine where it took 10 minutes to load this 1000 or 1500 records? Comment out the data access code and insert the same number of hard coded strings in a loop into the ListCtrls. Check what the time for this is. If it takes less time, then we can confirm that the issue is with db access, may be indexing is missing. Try this and see what the result is. cheers..Milton KB
the computer ...hm... is p4 2,6Ghz , 1Gb memory ,nVidia Gforce 5500 128 M the computer is not the problem ! Because i need this program to work to p2 233 Mhz ,64 M ! On both computers it takes ~10 min to load the data on my lists ( i have 6 tables - 1 table have ~1000 - 1500 maybe 3000 records ) and all will be loaded ! its a kill ! i don t have any ideea how can i do ... i remind you must work with my code ! Please help me!!!!!!!!!!!!!1
Bravoone
-
the computer ...hm... is p4 2,6Ghz , 1Gb memory ,nVidia Gforce 5500 128 M the computer is not the problem ! Because i need this program to work to p2 233 Mhz ,64 M ! On both computers it takes ~10 min to load the data on my lists ( i have 6 tables - 1 table have ~1000 - 1500 maybe 3000 records ) and all will be loaded ! its a kill ! i don t have any ideea how can i do ... i remind you must work with my code ! Please help me!!!!!!!!!!!!!1
Bravoone
the index its coll ,the database works fine (visualfoxpro db ((DBC))
Bravoone
-
how can i load from my database data to my CListCtrl fast ?because now i must wait up to 10 min to load the data ! i now (WM_TIMER and virtual list that is not a solution for me because i have all the code rady ! must be something ... this is the code : the FillList4 is loaded in my oninit dialog ! void CMyList::FillList4() { CNote *pNote = new CNote(); pNote->Open(); CString sNrInregistrare; if (pNote->GetRecordCount()) pNote->MoveFirst(); int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; } pNote->Close(); } ! Remember that : i have 4 CListCtrl to load with data 1 table have ~1000 and ~1500 data Please help me because i don t have any ideea at all ! Thanks !!!!! :)
Bravoone
-
CNote is CRecordset class default generated by microsoft visual c++
Bravoone
-
CNote is CRecordset class default generated by microsoft visual c++
Bravoone
i have the database on ODBC !
Bravoone
-
CNote is CRecordset class default generated by microsoft visual c++
Bravoone
I Googled around for "CRecordset slow" and found this at http://forums.mysql.com/read.php?45,99701,99721#msg-99721[^] The text: Resolved: Apparently, for whatever reason, Microsoft's CRecordset C/C++ class is literally copying the entire table over to the local client with the CRecordset::Open function. This is probably why the original coders were using a dynaset when we were using MSACCESS, but when I switched over to MYSQL, dynaset's were not supported with the MySQL/ODBC drivers so I used snapshots instead. I changed the logic to use a direct SQL command and its lightning fast now. Try my Google search (and variations). I guess you will find the reason (and the solution) of your problems. -- modified at 5:52 Wednesday 16th August, 2006 Don't ask me how to run a direct SQL query from your program, Iv'e never done it. But there is heaps of samples out there.
-
the index its coll ,the database works fine (visualfoxpro db ((DBC))
Bravoone
It looks ur hardware is more than enough and it should not take that much time. So issue is in ur CNote. its better u change that code with ADO or try whatever google link kakan mentioned. cheers..Milton KB
-
I Googled around for "CRecordset slow" and found this at http://forums.mysql.com/read.php?45,99701,99721#msg-99721[^] The text: Resolved: Apparently, for whatever reason, Microsoft's CRecordset C/C++ class is literally copying the entire table over to the local client with the CRecordset::Open function. This is probably why the original coders were using a dynaset when we were using MSACCESS, but when I switched over to MYSQL, dynaset's were not supported with the MySQL/ODBC drivers so I used snapshots instead. I changed the logic to use a direct SQL command and its lightning fast now. Try my Google search (and variations). I guess you will find the reason (and the solution) of your problems. -- modified at 5:52 Wednesday 16th August, 2006 Don't ask me how to run a direct SQL query from your program, Iv'e never done it. But there is heaps of samples out there.
ok i have find something but it must... change my all code and ... if is another way ?! Please help me !!!!!!!!!!!!!!!!!!!! i need an example ! please !
Bravoone
-
how can i load from my database data to my CListCtrl fast ?because now i must wait up to 10 min to load the data ! i now (WM_TIMER and virtual list that is not a solution for me because i have all the code rady ! must be something ... this is the code : the FillList4 is loaded in my oninit dialog ! void CMyList::FillList4() { CNote *pNote = new CNote(); pNote->Open(); CString sNrInregistrare; if (pNote->GetRecordCount()) pNote->MoveFirst(); int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; } pNote->Close(); } ! Remember that : i have 4 CListCtrl to load with data 1 table have ~1000 and ~1500 data Please help me because i don t have any ideea at all ! Thanks !!!!! :)
Bravoone
Flaviu_2006 wrote:
...i must wait up to 10 min to load the data !
How many items are being loaded? If it's more than just a few thousand, you'll need to use a "virtual" list control. What does
CNote::GetSQL()
look like?Flaviu_2006 wrote:
int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; }
If my code was not any better than what you had, then why are you using it? :rolleyes:
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
ok i have find something but it must... change my all code and ... if is another way ?! Please help me !!!!!!!!!!!!!!!!!!!! i need an example ! please !
Bravoone
Flaviu_2006 wrote:
ok i have find something but it must... change my all code and ... if is another way ?! Please help me !!!!!!!!!!!!!!!!!!!!
What is so hard about changing from dynaset to snapshot? :confused:
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
Flaviu_2006 wrote:
...i must wait up to 10 min to load the data !
How many items are being loaded? If it's more than just a few thousand, you'll need to use a "virtual" list control. What does
CNote::GetSQL()
look like?Flaviu_2006 wrote:
int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; }
If my code was not any better than what you had, then why are you using it? :rolleyes:
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
I think you modifiy his code in previous thread but i dont know why he doesnt try to use from answers
_**
**_
WhiteSky
-
how can i load from my database data to my CListCtrl fast ?because now i must wait up to 10 min to load the data ! i now (WM_TIMER and virtual list that is not a solution for me because i have all the code rady ! must be something ... this is the code : the FillList4 is loaded in my oninit dialog ! void CMyList::FillList4() { CNote *pNote = new CNote(); pNote->Open(); CString sNrInregistrare; if (pNote->GetRecordCount()) pNote->MoveFirst(); int x = 0; while(!pNote->IsEOF()) { int nItem = m_list4.InsertItem(x, pNote->m_name); m_list4.SetItemText(nItem, 1, pNote->m_city); pNote->MoveNext(); x++; } pNote->Close(); } ! Remember that : i have 4 CListCtrl to load with data 1 table have ~1000 and ~1500 data Please help me because i don t have any ideea at all ! Thanks !!!!! :)
Bravoone
Did you try to use from threads?
_**
**_
WhiteSky
-
I think you modifiy his code in previous thread but i dont know why he doesnt try to use from answers
_**
**_
WhiteSky
WhiteSky wrote:
I think you modifiy his code in previous thread...
I was not questioning that.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb