Is there a way to "clone" a sql data reader.
I have a lot of calls to the database to execute stored procedures. Everytime I need to execute a procedure I have to create a connection, open it, create a reader, create an sqlcommand, execute the command, save the result in the reader, then close the connection.
That's a lot of work everytime, so I've build a function to do that for me. All I have to do is to pass it the stored procedure name, and it does all of the above. Now my problem has to do with the reader. As you probably know, once the connection is closed, the reader is no longer available. My function is closing the connection, then returning the reader. If I don't close the connection (it stays open forever, which is not good!) Before closing the connection, can I "clone" (as was the case with recordsets in ASP) the reader (e.g. NewReader = Reader.Clone), then close the connection?
Is there a way I could do what I'm trying to do?
Thanks for your help
NaiDanac
I have a lot of calls to the database to execute stored procedures. Everytime I need to execute a procedure I have to create a connection, open it, create a reader, create an sqlcommand, execute the command, save the result in the reader, then close the connection.
That's a lot of work everytime, so I've build a function to do that for me. All I have to do is to pass it the stored procedure name, and it does all of the above. Now my problem has to do with the reader. As you probably know, once the connection is closed, the reader is no longer available. My function is closing the connection, then returning the reader. If I don't close the connection (it stays open forever, which is not good!) Before closing the connection, can I "clone" (as was the case with recordsets in ASP) the reader (e.g. NewReader = Reader.Clone), then close the connection?
Is there a way I could do what I'm trying to do?
Thanks for your help
NaiDanac