DataReader and Master-Detail

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi all,
I need to work through a master and its details table. My first attempt was to open a DataReader on the master and for each record get a new DataReader on the detail, restricted to the foreign key. But this is very slow. As the tables are very large I cannot use DataSet's functionality.
So my idea was to use a stored procedure for the detail reader that returns details in the same order as the master.
1) Can this be done with a stored procedure? How?
2) Is there a better way?

Thanks for any advice,

Christian

details.read();
while (master.Read()) {
int key = master.GetInt32(masterPrimaryKeyCol);
while (details.GetInt32(detailForeignKeyCol) == key) {
// process details
// ...
details.read();
} // while details
} // while master
.



Relevant Pages

  • Re: DataReader and Master-Detail
    ... When working with relational databases we use the SQL engine to return ... you can use the DataReader but why? ... Trying to pull rows from a parent table and related rows from a child table ... I need to work through a master and its details table. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataReader and Master-Detail
    ... If the calculations are too hard for TSQL, write a CLR executable (in any ... I need to do calculations on master ... Running through the records with a DataReader takes acceptable time (using ... restricted to the foreign key. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataReader and Master-Detail
    ... As I need to run through all shipments anyway, don't see an other way than using a DataReader. ... I could join the master and details, but this is more data in this flat table than in two hierarchical tables. ... The DataAdapter Fill method can return selected rows from several tables in a single operation if you aren't accessing JET. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataReader and Master-Detail
    ... You can sort the detail data using the same sort as the master day, ... DataReader on the detail, ... Can this be done with a stored procedure? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataReader and Master-Detail
    ... I guess it all depends on your query for the detail data. ... Opening a datareader isn't what isn't acceptable. ... I need to do calculations on master ... foreign key) as the master's primary key occur. ...
    (microsoft.public.dotnet.framework.adonet)