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. Database & SysAdmin
  3. Database
  4. Reader problem

Reader problem

Scheduled Pinned Locked Moved Database
databasealgorithmshelptutorial
8 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.
  • K Offline
    K Offline
    kjosh
    wrote on last edited by
    #1

    Hi, I have one method in the Data Access Layer like the below: LoadPersonsData() { IDataReader reader= db.ExecuteReader("Procedure name"); Now here I need to call another private metho which will load part of data. PersonData d = new PersonData(); While(reader.read()) { D.name =reader["fname"]; … D.Subdata = LoadSubdata(d, reader); D.DOB = reader["dob"]; } D.Subdata = LoadSubdata(d, reader); -- This line is also not getting the result D.DOB = reader["dob"]; -> The problem here is after loadSubData is called next I am trying to get the next field from reader, Here I am getting No data exist for the row or column. How to pass the datareader to LoadSubdata method. I just created the sub method to reduce the complexity complained by the DevPartner tool. Thanks

    F P C 4 Replies Last reply
    0
    • K kjosh

      Hi, I have one method in the Data Access Layer like the below: LoadPersonsData() { IDataReader reader= db.ExecuteReader("Procedure name"); Now here I need to call another private metho which will load part of data. PersonData d = new PersonData(); While(reader.read()) { D.name =reader["fname"]; … D.Subdata = LoadSubdata(d, reader); D.DOB = reader["dob"]; } D.Subdata = LoadSubdata(d, reader); -- This line is also not getting the result D.DOB = reader["dob"]; -> The problem here is after loadSubData is called next I am trying to get the next field from reader, Here I am getting No data exist for the row or column. How to pass the datareader to LoadSubdata method. I just created the sub method to reduce the complexity complained by the DevPartner tool. Thanks

      F Offline
      F Offline
      Frank Kerrigan
      wrote on last edited by
      #2

      The DataReader uses the connection exclusively and this may be your problem.

      Grady Booch: I told Google to their face...what you need is some serious adult supervision. (2007 Turing lecture) http://www.frankkerrigan.com/[^]

      1 Reply Last reply
      0
      • K kjosh

        Hi, I have one method in the Data Access Layer like the below: LoadPersonsData() { IDataReader reader= db.ExecuteReader("Procedure name"); Now here I need to call another private metho which will load part of data. PersonData d = new PersonData(); While(reader.read()) { D.name =reader["fname"]; … D.Subdata = LoadSubdata(d, reader); D.DOB = reader["dob"]; } D.Subdata = LoadSubdata(d, reader); -- This line is also not getting the result D.DOB = reader["dob"]; -> The problem here is after loadSubData is called next I am trying to get the next field from reader, Here I am getting No data exist for the row or column. How to pass the datareader to LoadSubdata method. I just created the sub method to reduce the complexity complained by the DevPartner tool. Thanks

        P Offline
        P Offline
        Prateek G
        wrote on last edited by
        #3

        In Reader.read() u r selecting a specific row and then u r sending whole reader it wont work, I think u should do it same function instead of calling another one...

        C 1 Reply Last reply
        0
        • P Prateek G

          In Reader.read() u r selecting a specific row and then u r sending whole reader it wont work, I think u should do it same function instead of calling another one...

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Prateek G wrote:

          then u r sending whole reader it wont work

          Why shouldn't it work?

          Prateek G wrote:

          I think u should do it same function instead of calling another one...

          Uugh! That way misery lies.


          Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

          P 1 Reply Last reply
          0
          • K kjosh

            Hi, I have one method in the Data Access Layer like the below: LoadPersonsData() { IDataReader reader= db.ExecuteReader("Procedure name"); Now here I need to call another private metho which will load part of data. PersonData d = new PersonData(); While(reader.read()) { D.name =reader["fname"]; … D.Subdata = LoadSubdata(d, reader); D.DOB = reader["dob"]; } D.Subdata = LoadSubdata(d, reader); -- This line is also not getting the result D.DOB = reader["dob"]; -> The problem here is after loadSubData is called next I am trying to get the next field from reader, Here I am getting No data exist for the row or column. How to pass the datareader to LoadSubdata method. I just created the sub method to reduce the complexity complained by the DevPartner tool. Thanks

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            Well, there may be something that is obviously wrong if you posted the ACTUAL code. The code you have posted contains several inconsistencies. You create a variable d and then appear to refer to it as D later on - these are separate variables and the code will not compile. Also, the problem is in LoadSubData, but you have not shown us what LoadSubData does. Please post the ACTUAL code if you want a chance to get a reasonable answer rather than blind guesses.


            Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

            1 Reply Last reply
            0
            • C Colin Angus Mackay

              Prateek G wrote:

              then u r sending whole reader it wont work

              Why shouldn't it work?

              Prateek G wrote:

              I think u should do it same function instead of calling another one...

              Uugh! That way misery lies.


              Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

              P Offline
              P Offline
              Prateek G
              wrote on last edited by
              #6

              In case I am reading Nth row reader must be having all the rows, How he will be able to select that particular row at that time.....

              C 1 Reply Last reply
              0
              • P Prateek G

                In case I am reading Nth row reader must be having all the rows, How he will be able to select that particular row at that time.....

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #7

                Prateek G wrote:

                In case I am reading Nth row reader must be having all the rows

                The reader disgorges one row at a time. If you pass a reader to a method it will be on what ever row that it was at when it was passed. The reader doesn't reset when it is passed around.

                Prateek G wrote:

                How he will be able to select that particular row at that time.....

                He most likely doesn't need to. He will be on the row he wants to read. You are making an awful lot of assumptions about what the OP is doing. The code he supplied is not valid and his description has many holes.


                Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

                1 Reply Last reply
                0
                • K kjosh

                  Hi, I have one method in the Data Access Layer like the below: LoadPersonsData() { IDataReader reader= db.ExecuteReader("Procedure name"); Now here I need to call another private metho which will load part of data. PersonData d = new PersonData(); While(reader.read()) { D.name =reader["fname"]; … D.Subdata = LoadSubdata(d, reader); D.DOB = reader["dob"]; } D.Subdata = LoadSubdata(d, reader); -- This line is also not getting the result D.DOB = reader["dob"]; -> The problem here is after loadSubData is called next I am trying to get the next field from reader, Here I am getting No data exist for the row or column. How to pass the datareader to LoadSubdata method. I just created the sub method to reduce the complexity complained by the DevPartner tool. Thanks

                  P Offline
                  P Offline
                  Prateek G
                  wrote on last edited by
                  #8

                  Can u paste the code of LoadSubdata(d, reader) function.. Are u using While(Reader.read()) method inside that function..

                  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