Hi there,
A DataReader will block the Connection as long as it is open. This means you cannot execute any other statement over the connection. Your code tries to execute the reader twice:
Code:
objDataReader = objCommand.ExecuteReader();
if(objDataReader.HasRows)
{
dgHouse.Visible = true;
dgHouse.DataSource = objCommand.ExecuteReader();
First you assign the result of the ExecuteReader method to the objDataReader, and then a few lines later, you use ExecuteReader again to fill the datasource. You should assign objDataReader to the DataSource property instead:
Code:
objDataReader = objCommand.ExecuteReader();
if(objDataReader.HasRows)
{
dgHouse.Visible = true;
dgHouse.DataSource = objDataReader;
This way, you only have one reader open at the time.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to:
Say Goodbye Hollywood by
Eminem (Track 8 from the album:
The Eminem Show)