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. While loop...

While loop...

Scheduled Pinned Locked Moved Visual Basic
helpdatabase
14 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.
  • S Subjugate

    i have a serious problem with my loop. My loop can only read the 1st data in my database even though there is 2 data inside. I think the problem should lays on my loop. Can u guys take a look at my loop and try to help me troubleshoot. Thanks a lot cos tis is urgent i got to pass up my proj soon. While TReader.Read And TReader2.Read And TReader3.Read And TReader4.Read strActionName = dTable.Rows(0)("ActionName") strStatus = dTable2.Rows(0)("Status") strFrequency = dTable3.Rows(0)("Frequency") strActionDone = dTable4.Rows(0)("ActionDone") strOneLine = ("ActionName = " + strActionName + "," + " Task = " + strActionDone + "," + " Frequency = " + strFrequency + "," + " Current Status = " + strStatus + "") MessageBox.Show(strOneLine) End While

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

    This is a disaster - why do you have four readers ?

    Christian Graus - C++ MVP

    S 1 Reply Last reply
    0
    • S Subjugate

      i have a serious problem with my loop. My loop can only read the 1st data in my database even though there is 2 data inside. I think the problem should lays on my loop. Can u guys take a look at my loop and try to help me troubleshoot. Thanks a lot cos tis is urgent i got to pass up my proj soon. While TReader.Read And TReader2.Read And TReader3.Read And TReader4.Read strActionName = dTable.Rows(0)("ActionName") strStatus = dTable2.Rows(0)("Status") strFrequency = dTable3.Rows(0)("Frequency") strActionDone = dTable4.Rows(0)("ActionDone") strOneLine = ("ActionName = " + strActionName + "," + " Task = " + strActionDone + "," + " Frequency = " + strFrequency + "," + " Current Status = " + strStatus + "") MessageBox.Show(strOneLine) End While

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #3

      What kind of objects are you using? How are the objects related? It looks kind of like you are reading from four tables simultaneously. Why would you do that? Can't you combine them into one result when you query the database?

      --- b { font-weight: normal; }

      C S 2 Replies Last reply
      0
      • C Christian Graus

        This is a disaster - why do you have four readers ?

        Christian Graus - C++ MVP

        S Offline
        S Offline
        Subjugate
        wrote on last edited by
        #4

        i use 4 reader because i need to read 4 rows from the same table and i dun know any other shorter way out. Any suggestion in how i should do it?

        C 1 Reply Last reply
        0
        • S Subjugate

          i use 4 reader because i need to read 4 rows from the same table and i dun know any other shorter way out. Any suggestion in how i should do it?

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

          Wow. Take a step back and do some reading.  If they are all in the same table, then you only need one reader, each row will contain all the values you need, assuming you select them.

          Christian Graus - C++ MVP

          S 1 Reply Last reply
          0
          • G Guffa

            What kind of objects are you using? How are the objects related? It looks kind of like you are reading from four tables simultaneously. Why would you do that? Can't you combine them into one result when you query the database?

            --- b { font-weight: normal; }

            S Offline
            S Offline
            Subjugate
            wrote on last edited by
            #6

            i dun understand ur question. Ya, i need to read 4 diff rows from the same table therefore i use 4 reader. I do not know any shorter way to combine in one result. Any suggestion on tis error u can provide me with??

            C 1 Reply Last reply
            0
            • G Guffa

              What kind of objects are you using? How are the objects related? It looks kind of like you are reading from four tables simultaneously. Why would you do that? Can't you combine them into one result when you query the database?

              --- b { font-weight: normal; }

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

              He's using four readers as he needs four columns from one table.  I suspect that's the core issue.

              Christian Graus - C++ MVP

              S 1 Reply Last reply
              0
              • S Subjugate

                i dun understand ur question. Ya, i need to read 4 diff rows from the same table therefore i use 4 reader. I do not know any shorter way to combine in one result. Any suggestion on tis error u can provide me with??

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

                Subjugate wrote:

                Ya, i need to read 4 diff rows from the same table therefore i use 4 reader

                You need four rows, or four columns ? If you need four rows, then you need to do a select that requests those four.  If you need four columns, your select statement should request those four.

                Christian Graus - C++ MVP

                1 Reply Last reply
                0
                • C Christian Graus

                  Wow. Take a step back and do some reading.  If they are all in the same table, then you only need one reader, each row will contain all the values you need, assuming you select them.

                  Christian Graus - C++ MVP

                  S Offline
                  S Offline
                  Subjugate
                  wrote on last edited by
                  #9

                  DO u have any site where by i am able to read the information i like. I am quite a noob to coding. Or do u have any sample code on that?

                  C 1 Reply Last reply
                  0
                  • C Christian Graus

                    He's using four readers as he needs four columns from one table.  I suspect that's the core issue.

                    Christian Graus - C++ MVP

                    S Offline
                    S Offline
                    Subjugate
                    wrote on last edited by
                    #10

                    Ya.. sori for my explanation error i need 4 columns from the same table. U mean i just need to use the SELECT sql to retrieve my 4 columns?

                    C 1 Reply Last reply
                    0
                    • S Subjugate

                      DO u have any site where by i am able to read the information i like. I am quite a noob to coding. Or do u have any sample code on that?

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

                      You're on a site full of articles.  But, if you're really that new, then you really need to take a step back, and work through a book or two. http://msdn.microsoft.com [^] is full of info as well, but this [^]is the best way to search it, use site:msdn.microsoft.com in your search string.

                      Christian Graus - C++ MVP

                      1 Reply Last reply
                      0
                      • S Subjugate

                        Ya.. sori for my explanation error i need 4 columns from the same table. U mean i just need to use the SELECT sql to retrieve my 4 columns?

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

                        Yes, if you do a Select *, then all four columns will be read.  dTable3.Rows(0)("Frequency") is reading the Frequency column, that's how you specify any column on the one reader.

                        Christian Graus - C++ MVP

                        S 1 Reply Last reply
                        0
                        • C Christian Graus

                          Yes, if you do a Select *, then all four columns will be read.  dTable3.Rows(0)("Frequency") is reading the Frequency column, that's how you specify any column on the one reader.

                          Christian Graus - C++ MVP

                          S Offline
                          S Offline
                          Subjugate
                          wrote on last edited by
                          #13

                          oh ok... i understand wat u mean already.. thanks a lot u guys help... Learn sumthing new today.. :)

                          1 Reply Last reply
                          0
                          • S Subjugate

                            i have a serious problem with my loop. My loop can only read the 1st data in my database even though there is 2 data inside. I think the problem should lays on my loop. Can u guys take a look at my loop and try to help me troubleshoot. Thanks a lot cos tis is urgent i got to pass up my proj soon. While TReader.Read And TReader2.Read And TReader3.Read And TReader4.Read strActionName = dTable.Rows(0)("ActionName") strStatus = dTable2.Rows(0)("Status") strFrequency = dTable3.Rows(0)("Frequency") strActionDone = dTable4.Rows(0)("ActionDone") strOneLine = ("ActionName = " + strActionName + "," + " Task = " + strActionDone + "," + " Frequency = " + strFrequency + "," + " Current Status = " + strStatus + "") MessageBox.Show(strOneLine) End While

                            M Offline
                            M Offline
                            MyFathersSon
                            wrote on last edited by
                            #14

                            assuming you've a data control data1.refresh data1.recordsource = "select * from yourdb" data1.recordset.movefirst do while not data1.recordset.eof strFirstField = data1.recordset.fields("Field1").value strSecondField = data1.recordset.fields("Field2").value data1.recordset.movenext loop

                            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