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. Visual Basic
  4. progress bar

progress bar

Scheduled Pinned Locked Moved Visual Basic
databasetutorial
15 Posts 4 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
    charchabil03
    wrote on last edited by
    #1

    Hello Can you provide me a simple function of how to use Progress bar while pulling an unknown number of data from a database thx

    Regards Ramy

    C X 2 Replies Last reply
    0
    • C charchabil03

      Hello Can you provide me a simple function of how to use Progress bar while pulling an unknown number of data from a database thx

      Regards Ramy

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Quite plainly, if you don't know how much data you are getting, there's no way you can show a real progress bar. You should also try to make your database call all in one go, not breaking it up into many calls if you can help it. Your best bet is to set a progress bar to just show indeterminate progress ( the bar moves over and over ) and leave that showing while a thread does your DB call.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • C charchabil03

        Hello Can you provide me a simple function of how to use Progress bar while pulling an unknown number of data from a database thx

        Regards Ramy

        X Offline
        X Offline
        Xandip
        wrote on last edited by
        #3

        ya tats right.. i had posted the same question days ago, and got the same answer from the members of this group. Any ways, try to loop the value of the progressbar with the number of recordsets you want to load. Place the function in a timer with an interval of say 1000 ms. hope this works..

        The name is Sandeep

        C 1 Reply Last reply
        0
        • X Xandip

          ya tats right.. i had posted the same question days ago, and got the same answer from the members of this group. Any ways, try to loop the value of the progressbar with the number of recordsets you want to load. Place the function in a timer with an interval of say 1000 ms. hope this works..

          The name is Sandeep

          C Offline
          C Offline
          charchabil03
          wrote on last edited by
          #4

          Kindly,Provide me a simple code for that :) thank you

          Regards Ramy

          C X 2 Replies Last reply
          0
          • C charchabil03

            Kindly,Provide me a simple code for that :) thank you

            Regards Ramy

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            What he has suggested is plain not going to work. Set your progress bar Style property to Marquee and do what I said, there is just no way you can show a progress bar for an unknown number of items.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            C 1 Reply Last reply
            0
            • C Christian Graus

              What he has suggested is plain not going to work. Set your progress bar Style property to Marquee and do what I said, there is just no way you can show a progress bar for an unknown number of items.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              C Offline
              C Offline
              charchabil03
              wrote on last edited by
              #6

              Thx for ur help I really appreciate it. ( and i m not complaining) all what i ask is a simple code please thx

              Regards Ramy

              C 1 Reply Last reply
              0
              • C charchabil03

                Thx for ur help I really appreciate it. ( and i m not complaining) all what i ask is a simple code please thx

                Regards Ramy

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                If you set the progress bar style to marquee, it will display itself automatically. Just put one on your form, and then do your database call in a thread. When the thread ends, get rid of the progress bar. I'm sorry, but I don't write VB, and really, there's no code that I can show you, you need no code for the progress bar, and I don't know how your database call is written.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                C X 2 Replies Last reply
                0
                • C charchabil03

                  Kindly,Provide me a simple code for that :) thank you

                  Regards Ramy

                  X Offline
                  X Offline
                  Xandip
                  wrote on last edited by
                  #8

                  Is This for VB6 or VB.NET??

                  The name is Sandeep

                  C 1 Reply Last reply
                  0
                  • X Xandip

                    Is This for VB6 or VB.NET??

                    The name is Sandeep

                    C Offline
                    C Offline
                    charchabil03
                    wrote on last edited by
                    #9

                    guys it's a vb.net application fdbcon.Open() fdbcmd.CommandText = "select * from table" dr = fdbcmd.ExecuteReader fdbcon.Open() that is all

                    Regards Ramy

                    C 1 Reply Last reply
                    0
                    • C Christian Graus

                      If you set the progress bar style to marquee, it will display itself automatically. Just put one on your form, and then do your database call in a thread. When the thread ends, get rid of the progress bar. I'm sorry, but I don't write VB, and really, there's no code that I can show you, you need no code for the progress bar, and I don't know how your database call is written.

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      C Offline
                      C Offline
                      charchabil03
                      wrote on last edited by
                      #10

                      thx for ur help :)

                      Regards Ramy

                      1 Reply Last reply
                      0
                      • C charchabil03

                        guys it's a vb.net application fdbcon.Open() fdbcmd.CommandText = "select * from table" dr = fdbcmd.ExecuteReader fdbcon.Open() that is all

                        Regards Ramy

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        So use the BackgroundWorker class to do this in a thread, and in it's finished event, hide the progress bar. Your only other problem is, do you also disable the rest of the UI during the call ? The easiest way to do that is have a modal call on a progress dialog, which calls the thread, and then closes itself when the call is done.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          If you set the progress bar style to marquee, it will display itself automatically. Just put one on your form, and then do your database call in a thread. When the thread ends, get rid of the progress bar. I'm sorry, but I don't write VB, and really, there's no code that I can show you, you need no code for the progress bar, and I don't know how your database call is written.

                          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          X Offline
                          X Offline
                          Xandip
                          wrote on last edited by
                          #12

                          Christian Graus wrote:

                          I'm sorry, but I don't write VB

                          then start writing and THEN give your suggestions... So whats the idea?? Changing the style of the progress bar? wats the matter if u get the count of the records that has to be processed..(as i said earlier)

                          Christian Graus wrote:

                          there's no code that I can show you

                          but i can show you.. With flxTest .Clear .Rows = 1 .Cols = 5 Call GetConnection 'Function Set Gadors = New ADODB.Recordset GNewQuery = "SELECT * FROM test" Gadors.Open GNewQuery, Gadocn Gadors.MoveFirst Dim i As Long pg.Min = 0 'setting values of progressbar pg.Max = Gadors.RecordCount MousePointer = vbHourglass While Gadors.EOF = False i = .Rows .Rows = .Rows + 1 .TextMatrix(i, 0) = Gadors.Fields(0) .TextMatrix(i, 1) = Gadors.Fields(1) .TextMatrix(i, 2) = Gadors.Fields(2) .TextMatrix(i, 3) = Gadors.Fields(3) .TextMatrix(i, 4) = Gadors.Fields(4) If pg.Value <> Gadors.RecordCount Then pg.Value = pg.Value + 1 Gadors.MoveNext flxTest.Refresh Wend MousePointer = vbDefault End With try this one....

                          The name is Sandeep

                          D C 2 Replies Last reply
                          0
                          • X Xandip

                            Christian Graus wrote:

                            I'm sorry, but I don't write VB

                            then start writing and THEN give your suggestions... So whats the idea?? Changing the style of the progress bar? wats the matter if u get the count of the records that has to be processed..(as i said earlier)

                            Christian Graus wrote:

                            there's no code that I can show you

                            but i can show you.. With flxTest .Clear .Rows = 1 .Cols = 5 Call GetConnection 'Function Set Gadors = New ADODB.Recordset GNewQuery = "SELECT * FROM test" Gadors.Open GNewQuery, Gadocn Gadors.MoveFirst Dim i As Long pg.Min = 0 'setting values of progressbar pg.Max = Gadors.RecordCount MousePointer = vbHourglass While Gadors.EOF = False i = .Rows .Rows = .Rows + 1 .TextMatrix(i, 0) = Gadors.Fields(0) .TextMatrix(i, 1) = Gadors.Fields(1) .TextMatrix(i, 2) = Gadors.Fields(2) .TextMatrix(i, 3) = Gadors.Fields(3) .TextMatrix(i, 4) = Gadors.Fields(4) If pg.Value <> Gadors.RecordCount Then pg.Value = pg.Value + 1 Gadors.MoveNext flxTest.Refresh Wend MousePointer = vbDefault End With try this one....

                            The name is Sandeep

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            Your updating the progress bar AFTER the records have been returned, not during. Your only updaating the progress bar during the processing of each record. For a long running stored procedure that returns a set of records, or for an unknown size of the set, this won't work at all.

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                 2006, 2007

                            1 Reply Last reply
                            0
                            • X Xandip

                              Christian Graus wrote:

                              I'm sorry, but I don't write VB

                              then start writing and THEN give your suggestions... So whats the idea?? Changing the style of the progress bar? wats the matter if u get the count of the records that has to be processed..(as i said earlier)

                              Christian Graus wrote:

                              there's no code that I can show you

                              but i can show you.. With flxTest .Clear .Rows = 1 .Cols = 5 Call GetConnection 'Function Set Gadors = New ADODB.Recordset GNewQuery = "SELECT * FROM test" Gadors.Open GNewQuery, Gadocn Gadors.MoveFirst Dim i As Long pg.Min = 0 'setting values of progressbar pg.Max = Gadors.RecordCount MousePointer = vbHourglass While Gadors.EOF = False i = .Rows .Rows = .Rows + 1 .TextMatrix(i, 0) = Gadors.Fields(0) .TextMatrix(i, 1) = Gadors.Fields(1) .TextMatrix(i, 2) = Gadors.Fields(2) .TextMatrix(i, 3) = Gadors.Fields(3) .TextMatrix(i, 4) = Gadors.Fields(4) If pg.Value <> Gadors.RecordCount Then pg.Value = pg.Value + 1 Gadors.MoveNext flxTest.Refresh Wend MousePointer = vbDefault End With try this one....

                              The name is Sandeep

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #14

                              Xandip wrote:

                              then start writing and THEN give your suggestions...

                              Most of the questions here are framework questions, which is why I can answer them. I *can* write VB, but I'd prefer not to.

                              Xandip wrote:

                              but i can show you..

                              Like Dave said, this won't work. What I explained, will.

                              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                              X 1 Reply Last reply
                              0
                              • C Christian Graus

                                Xandip wrote:

                                then start writing and THEN give your suggestions...

                                Most of the questions here are framework questions, which is why I can answer them. I *can* write VB, but I'd prefer not to.

                                Xandip wrote:

                                but i can show you..

                                Like Dave said, this won't work. What I explained, will.

                                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                                X Offline
                                X Offline
                                Xandip
                                wrote on last edited by
                                #15

                                In the case of stored procedures, I admit what Dave said. But I dont understand why you are saying to display a progressbar in the screen just for a Show sake. Whats the use of it, if it doesnt show even the approximate time taken for loading the set of records..? The progressbar loading is used for making the user wait upto some time, till the data shows up. If its the case of stored procedures, my code can be inserted during the data loading time, because stored procedures still shows the recordcount. At least, the user can see the time spent in the data showup process.

                                Christian Graus wrote:

                                What I explained, will.

                                I really dont like the idea of fooling a user with your 'just for show' progressbar. I admit that my idea is not the appropriate solution, but still I can't stand with yours. The amount of time for presenting the data in front of the user can be precisely split up into the time for data retrieval + time for data viewing time for data retrieval -> this one, i admit, cannot be done time for data viewing -> but you have to admit, this one can be done

                                The name is Sandeep

                                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