If I a use a single connection for a datareader object, can I also use that same connection object for other things or do I have to wait until the datareader is finished with it?
You can use one single connection object through your entire page if you need to. What do you mean by using the same connectiong before the datareader is finished? what are you trying to do?
As I am reading my first datareader, I want to create another one before I am done with the first, so I will have to datareaders open at the same time. I want to use the same connection object for both. I thought I read somewhere that you can't do that (but I'm sure that's not the case)...
To my best knowledge:
the datareader is the only .net data object that will keep a connection open. While you are using the first datareader, the database will put a lock on the table/s you are reading and hold the lock until the datareader has completed going through all the records. Therefore the second datareader will not be able to read the those tables at that time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.