Problem with Datareader.close

A

andy

Hi,

I have an asp.net application and am facing a problem while closing my
datareader object. I am using Active reports for dotnet for generating
reports.

I create a datareader object in my data access layer and then pass it
to the calling function ( I know this isnt a good practice, but I cant
change this). I am using the commandbehaviour.closeconnection property
while opening the datareader. The problem occurs when the
Datareader.close() function is called, the page just hangs there and
nothing happens!. I am unable to understand why this happens. I
checked the connection state when I'm calling close , it shows that
the connection state is Open.

The code works fine on one of my development machines but hangs on two
other machines. I'm attaching the code where I'm getting a problem.
Please let me know if you can see any errors or why I'm facing this
problem.


private void rpt_Report1_ReportStart(object sender, System.EventArgs
{
try
{
ReportHelper rh=new ReportHelper();
//SQL Query
StringBuilder sbSQL=new StringBuilder();
sbSQL.Append("SELECT * from tablename");
mReader=SqlHelper.ExecuteReader(mConnString,CommandType.Text,sbSQL.ToString());
sbSQL=null;
rh=null;
}
}


private void rpt_Report1_ReportEnd(object sender, System.EventArgs
eArgs)
{
mReader.Close();
mReader=null;
}


Thanks in advance

Andy
 
G

Guest

Consider creating the connection, command and dataReader and then passing in
the command and datareader to your DAL. It may hang as it is trying to find
and clsoe the underlying connection.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top