Reader problem
-
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
-
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
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/[^]
-
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
-
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...
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
-
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
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
-
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
-
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.....
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
-
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