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. vb try to skip some data while reading?? [urgent]

vb try to skip some data while reading?? [urgent]

Scheduled Pinned Locked Moved Visual Basic
csshelptutorialquestion
11 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
    campbells
    wrote on last edited by
    #1

    i haveing an error while running my coding which is to pass the info from the data grid to EXCEL... it pass correctly at first but when it try to pass the last 3 row then error pops up : Runtime error '6148' invalid row number. when i try to check my excel the last print out b4 error happen,it refer to the data grid last row info which mean it try to skip to the last row... so when the system try to read next time there was no more line to read... i have check my code many time i dunno y the vb just skip the line itself.... For example again: datagrid row 10 = EXCEL row 10 but the EXCEL row 10 have print out datagrid row 20... i = 3 'ROW j = 2 'Column For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr DataGrid1.Col = dc ApExcel.Cells(i + 1, j).Value = DataGrid1.Text 'Pass info from data grid to EXCEL j = j + 1 Next dc j = 2 i = i + 1 Next dr

    A S D 3 Replies Last reply
    0
    • C campbells

      i haveing an error while running my coding which is to pass the info from the data grid to EXCEL... it pass correctly at first but when it try to pass the last 3 row then error pops up : Runtime error '6148' invalid row number. when i try to check my excel the last print out b4 error happen,it refer to the data grid last row info which mean it try to skip to the last row... so when the system try to read next time there was no more line to read... i have check my code many time i dunno y the vb just skip the line itself.... For example again: datagrid row 10 = EXCEL row 10 but the EXCEL row 10 have print out datagrid row 20... i = 3 'ROW j = 2 'Column For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr DataGrid1.Col = dc ApExcel.Cells(i + 1, j).Value = DataGrid1.Text 'Pass info from data grid to EXCEL j = j + 1 Next dc j = 2 i = i + 1 Next dr

      A Offline
      A Offline
      aparna shukla1
      wrote on last edited by
      #2

      use :- For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr+1 ' as 0 is not a valid row

      IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

      C 1 Reply Last reply
      0
      • A aparna shukla1

        use :- For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr+1 ' as 0 is not a valid row

        IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

        C Offline
        C Offline
        campbells
        wrote on last edited by
        #3

        i run ok for the 0 which mean the first line. when it go to the 11 line then something goes wrong with the data it will get the last value of the data. u know wat i mean? when it get the last data of the last row but which is not. when it go to the next row, there is nothing to get so error came out. But i didnt control the VB to skip the 11 line...

        A 1 Reply Last reply
        0
        • C campbells

          i haveing an error while running my coding which is to pass the info from the data grid to EXCEL... it pass correctly at first but when it try to pass the last 3 row then error pops up : Runtime error '6148' invalid row number. when i try to check my excel the last print out b4 error happen,it refer to the data grid last row info which mean it try to skip to the last row... so when the system try to read next time there was no more line to read... i have check my code many time i dunno y the vb just skip the line itself.... For example again: datagrid row 10 = EXCEL row 10 but the EXCEL row 10 have print out datagrid row 20... i = 3 'ROW j = 2 'Column For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr DataGrid1.Col = dc ApExcel.Cells(i + 1, j).Value = DataGrid1.Text 'Pass info from data grid to EXCEL j = j + 1 Next dc j = 2 i = i + 1 Next dr

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

          campbells wrote:

          For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr

          I am not entirely sure I understand your problem, but should not you put the line "DataGrid1.Row = dr" between "For dr = 0 To (Adodc1.Recordset.RecordCount - 1)" AND For dc = 0 To (DataGrid1.Columns.Count - 1)" so that the row is changed after all the columns are processed? Hope this helps.

          Shreekar http://shreekarishere.blogspot.com

          C 1 Reply Last reply
          0
          • C campbells

            i run ok for the 0 which mean the first line. when it go to the 11 line then something goes wrong with the data it will get the last value of the data. u know wat i mean? when it get the last data of the last row but which is not. when it go to the next row, there is nothing to get so error came out. But i didnt control the VB to skip the 11 line...

            A Offline
            A Offline
            aparna shukla1
            wrote on last edited by
            #5

            on which line and text error occurs ? either datagrid1.text or other ? IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

            C 1 Reply Last reply
            0
            • A aparna shukla1

              on which line and text error occurs ? either datagrid1.text or other ? IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

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

              the code which i have underline it. I know y there is an error because when i read there is no more information cause it have skip to the last line which i did not ask it to do so... so i not sure happen with the system.... when i run the system i check one by one... example, suppose it will pass 14 row with 5 column information each of it. when it goes to row 12, then the first 2 colum data which is not the correct one the vb itself have skip to row 13-14 and get the value. after that sure it will have error becasue when it try to read the row 13, but the arrow have been point to the last 14 row b4 when it put the value to row 12, so the next data will be 15 which is an empty one.

              1 Reply Last reply
              0
              • S shreekar

                campbells wrote:

                For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr

                I am not entirely sure I understand your problem, but should not you put the line "DataGrid1.Row = dr" between "For dr = 0 To (Adodc1.Recordset.RecordCount - 1)" AND For dc = 0 To (DataGrid1.Columns.Count - 1)" so that the row is changed after all the columns are processed? Hope this helps.

                Shreekar http://shreekarishere.blogspot.com

                C Offline
                C Offline
                campbells
                wrote on last edited by
                #7

                at first the DR which mean the row~ since i'm showing the data in the datagrid first, then pass to EXCEL. DC which is the column , which there is 5 column. when goes to row 1, then pass the datagrid column data to excel, after passing the row 1 column data, then next dr which is ROW 2.

                A 1 Reply Last reply
                0
                • C campbells

                  at first the DR which mean the row~ since i'm showing the data in the datagrid first, then pass to EXCEL. DC which is the column , which there is 5 column. when goes to row 1, then pass the datagrid column data to excel, after passing the row 1 column data, then next dr which is ROW 2.

                  A Offline
                  A Offline
                  aparna shukla1
                  wrote on last edited by
                  #8

                  try this for dr =0 to datagrid1.rows-1 IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

                  C 1 Reply Last reply
                  0
                  • A aparna shukla1

                    try this for dr =0 to datagrid1.rows-1 IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

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

                    dc suppose to be column...?? For dc = 0 To (DataGrid1.Columns.Count - 1)

                    A 1 Reply Last reply
                    0
                    • C campbells

                      dc suppose to be column...?? For dc = 0 To (DataGrid1.Columns.Count - 1)

                      A Offline
                      A Offline
                      aparna shukla1
                      wrote on last edited by
                      #10

                      i m so sorry for dr =0 to datagrid1.rows-1

                      IT IS NOT AS IMPORTANT AS WHETHER YOU SUCCEED OR FAIL BUT WHAT IMPORTANT IS THAT YOU TRY YOUR BEST. SO ALWAYS TRY AT YOUR LEVEL BEST

                      1 Reply Last reply
                      0
                      • C campbells

                        i haveing an error while running my coding which is to pass the info from the data grid to EXCEL... it pass correctly at first but when it try to pass the last 3 row then error pops up : Runtime error '6148' invalid row number. when i try to check my excel the last print out b4 error happen,it refer to the data grid last row info which mean it try to skip to the last row... so when the system try to read next time there was no more line to read... i have check my code many time i dunno y the vb just skip the line itself.... For example again: datagrid row 10 = EXCEL row 10 but the EXCEL row 10 have print out datagrid row 20... i = 3 'ROW j = 2 'Column For dr = 0 To (Adodc1.Recordset.RecordCount - 1) For dc = 0 To (DataGrid1.Columns.Count - 1) DataGrid1.Row = dr DataGrid1.Col = dc ApExcel.Cells(i + 1, j).Value = DataGrid1.Text 'Pass info from data grid to EXCEL j = j + 1 Next dc j = 2 i = i + 1 Next dr

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

                        The problem is that your assuming that a DataGrid row is the same as a Row in the Dataset. It's not. You shouldn't even be getting the data out of the DataGrid. Just use the RecordSet object as your source of data to copy to the Excel sheet. The DataGrid is just for showing and editing what's in the RecordSet, keep it that way. Now, since you're using VB.NET, why are you using the old ADODB objects when the .NET Framework provides much better and easier to use DataSet classes?

                        Dave Kreskowiak Microsoft MVP - Visual Basic

                        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