By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,899 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,899 IT Pros & Developers. It's quick & easy.

There is already an open DataReader associated with this Command which must be closed

P: 1
I am using visual studio 2012 with SqlServer 2008.
while developing a website, i used datareader
when i wanted to use the datareader again for reading another table data from the same database, i get the error"There is already an open DataReader associated with this Command which must be closed first".
I have used datareader.Close(), it does not help;
I have used datareade.Dispose(), this also does not help;
I have also used using( Datareader ----) it was no help;
I have also used try ( --- ) catch (SqlException)
still i get the same error,
Can any one help. I am stuck because i need to read data a number of times in this web site.
any kind of help or alternative to read data from same database multilpe times will be appreciated.
May 7 '13 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,359
I don't use .Net much so I probably can't answer the question but I know that whoever can answer your question won't be able to because you haven't shown us the code that produces the error.
May 7 '13 #2

100+
P: 158
Hey yogeshraj, datareader.Close() method should work.
May 7 '13 #3

P: 2
yogeshraj,
You cant perform any operation with datareader result.if you want to perform any action with result then you have to use dataset and fetch result with foreach and perform action..

Thanks & regards,
rajeshk
May 8 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.