Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question

1 Answer

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

Its now working exactly the way I wanted it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.