views:

9

answers:

1

Hi I need some advice as to whether what I am trying to acheive is even possible.

I have code which is basically

    SqlDataReader sourceDataReader = dbFunctions.getDataReader(<..some parameters..>)
    while (sourceDataReader.Read())
    {
         .....
         Do some stuff
         .....
         // Write out record
         dbFunctions.writeRecord((<..some parameters..>)
    }

What I would like to do, is to somehow "move" out this code (the while loop etc.) of the DataReader to my functions library (dbFunctions). Something like this

SqlDataReader sourceDataReader = dbFunctions.getDataReader(<..some parameters..>)
// 
// Somehow define the function for calling back
//
dbFunctions.ReadData(sourceDataReader, <..some parameters..>)

public void myCallbackFunction(<..Row Data from SQLDataReader..>)
{
     // Do something with the data
     ....
     ....
     // Write out record
     dbFunctions.writeRecord((<..some parameters..>)    
}

I have looked at some kind of asynchronous call back from the SQL Reader but can't quite get my head around it.

Any pointers would be most welcome - if I can add any further detail, I will

Roger Somerset UK

A: 

The answers to this question put clarity on the whole topic for me.

Its now working exactly the way I wanted it.

Roger Maynard