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. MFC (database) please help !

MFC (database) please help !

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++databasehelp
15 Posts 5 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.
  • B Offline
    B Offline
    Bravoone_2006
    wrote on last edited by
    #1

    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

    M K D H 4 Replies Last reply
    0
    • B Bravoone_2006

      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

      M Offline
      M Offline
      Milton Karimbekallil
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • M Milton Karimbekallil

        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

        B Offline
        B Offline
        Bravoone_2006
        wrote on last edited by
        #3

        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

        B 1 Reply Last reply
        0
        • B Bravoone_2006

          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

          B Offline
          B Offline
          Bravoone_2006
          wrote on last edited by
          #4

          the index its coll ,the database works fine (visualfoxpro db ((DBC))

          Bravoone

          M 1 Reply Last reply
          0
          • B Bravoone_2006

            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

            K Offline
            K Offline
            kakan
            wrote on last edited by
            #5

            The problem might be in your class CNote. What does it look like?

            B 1 Reply Last reply
            0
            • K kakan

              The problem might be in your class CNote. What does it look like?

              B Offline
              B Offline
              Bravoone_2006
              wrote on last edited by
              #6

              CNote is CRecordset class default generated by microsoft visual c++

              Bravoone

              B K 2 Replies Last reply
              0
              • B Bravoone_2006

                CNote is CRecordset class default generated by microsoft visual c++

                Bravoone

                B Offline
                B Offline
                Bravoone_2006
                wrote on last edited by
                #7

                i have the database on ODBC !

                Bravoone

                1 Reply Last reply
                0
                • B Bravoone_2006

                  CNote is CRecordset class default generated by microsoft visual c++

                  Bravoone

                  K Offline
                  K Offline
                  kakan
                  wrote on last edited by
                  #8

                  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.

                  B 1 Reply Last reply
                  0
                  • B Bravoone_2006

                    the index its coll ,the database works fine (visualfoxpro db ((DBC))

                    Bravoone

                    M Offline
                    M Offline
                    Milton Karimbekallil
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • K kakan

                      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.

                      B Offline
                      B Offline
                      Bravoone_2006
                      wrote on last edited by
                      #10

                      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

                      D 1 Reply Last reply
                      0
                      • B Bravoone_2006

                        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

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        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

                        H 1 Reply Last reply
                        0
                        • B Bravoone_2006

                          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

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          • D David Crow

                            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

                            H Offline
                            H Offline
                            Hamid Taebi
                            wrote on last edited by
                            #13

                            I think you modifiy his code in previous thread but i dont know why he doesnt try to use from answers

                            _**


                            **_

                            WhiteSky


                            D 1 Reply Last reply
                            0
                            • B Bravoone_2006

                              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

                              H Offline
                              H Offline
                              Hamid Taebi
                              wrote on last edited by
                              #14

                              Did you try to use from threads?

                              _**


                              **_

                              WhiteSky


                              1 Reply Last reply
                              0
                              • H Hamid Taebi

                                I think you modifiy his code in previous thread but i dont know why he doesnt try to use from answers

                                _**


                                **_

                                WhiteSky


                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #15

                                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

                                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