Microsoft
Software
Hardware
Network
Question : Rendering timeout when calling report through C# code
The timeout on our SQL 2005 Reporting Services is set to 1800 seconds. When I call the report through code by making an instance of the reporting service on my web page, it times out after like 45 seconds.
The code being used to render the report is:
protected void BtnProcessOnDemand_Click(o
bject sender, EventArgs e)
{
this.LblError.Visible = false;
this.LblError.Text = "";
//initialize variables
String SITEID = "%";
String DIVID = "%";
String BENGROUPID = "%";
DateTime PREMDATE = System.DateTime.Now;
if (TxtRptPremDate.Text.Lengt
h > 0)
{
PREMDATE = Convert.ToDateTime(TxtRptP
remDate.Te
xt.ToStrin
g());
}
else
{
LblError.Text = "Please input a premium date.";
LblError.Visible = true;
return;
}
if (DdlSite.SelectedIndex != 0)
{
SITEID = DdlSite.SelectedValue;
if (DdlDivision.SelectedIndex
!= 0)
{
DIVID = DdlDivision.SelectedValue;
if (DdlBenGroup.SelectedIndex
!= 0)
{
BENGROUPID = DdlBenGroup.SelectedValue;
}
}
}
//if (((Button)sender).CommandN
ame.ToStri
ng() != LblHidden.Text)
//{
String error = "";
ReportExecutionService RE = new ReportExecutionService();
RE.Credentials = new System.Net.NetworkCredenti
al("Userna
me", "Password", "Domain");
RE.Url = "
http://report.ntlbenefit.
com/report
server/
rep
ortexecuti
on2005.asm
x?wsdl
";
// Render arguments
DataSet pathdir = SC.get_path();
DataSet report = SC.get_reportinfo(DdlRepor
tsOD.Selec
tedValue.T
oString())
;
byte[] result = null;
string reportPath = "/" + pathdir.Tables[0].Rows[0][
"path_fold
er"].ToStr
ing() + "/" + report.Tables[0].Rows[0]["
rpt_link"]
.ToString(
);
string format = DdlFormat.SelectedValue.To
String();
string historyID = null;
string devInfo = @"
Fal
ser>Info>";
// Prepare report parameter.
ParameterValue[] parameters = new ParameterValue[5];
parameters[0] = new ParameterValue();
parameters[0].Name = "SITEID";
parameters[0].Value = SITEID;
parameters[1] = new ParameterValue();
parameters[1].Name = "DIVID";
parameters[1].Value = DIVID;
parameters[2] = new ParameterValue();
parameters[2].Name = "BENGROUPID";
parameters[2].Value = BENGROUPID;
parameters[3] = new ParameterValue();
parameters[3].Name = "PREMDATE";
parameters[3].Value = PREMDATE.ToString();
parameters[4] = new ParameterValue();
parameters[4].Name = "ADMINID";
parameters[4].Value = Session["AdminID"].ToStrin
g();
//LblError.Text = reportPath;
//LblError.Visible = true;
//return;
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
string extension;
string actualextension;
actualextension = DdlFormat.SelectedValue.To
String();
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
ExecutionInfo execInfo = new ExecutionInfo();
ExecutionHeader execHeader = new ExecutionHeader();
RE.ExecutionHeaderValue = execHeader;
try
{
execInfo = RE.LoadReport(reportPath, historyID);
}
catch (Exception eload)
{
this.LblError.Text = "The requested report is not available, please check back soon.";
this.LblError.Visible = true;
return;
}
RE.SetExecutionParameters(
parameters
, "en-us");
String SessionId = RE.ExecutionHeaderValue.Ex
ecutionID;
try
{
result = RE.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
}
catch (SoapException soape)
{
error = soape.ToString() + " br>";
}
// Write the contents of the report to an MHTML file.
try
{
String guid = Guid.NewGuid().ToString();
FileStream stream = File.Create(Server.MapPath
("~/Temp/"
+ guid + "." + actualextension), result.Length);
stream.Write(result, 0, result.Length);
stream.Close();
LblHidden.Text = report.Tables[0].Rows[0]["
rpt_link"]
.ToString(
);
//this.PnlConfirm.Visible = true;
LblDisplay.Text = "
"
;
}
catch (Exception ex)
{
error = ex.ToString() + " br>";
}
if (error.Length > 0)
{
this.LblError.Text = error.ToString();
this.LblError.Visible = true;
}
//}
}
When developing a sql statement in my webservice I can set how long it takes to time out the connection. Is there a similar function when rendering from a page. Some of these reports take 10 to 15 minutes to generate.
Any help would be greatly appreciated.
Answer : Rendering timeout when calling report through C# code
can think of couple of suggestions:
-make sure the timeout value is in seconds and not milliseconds
-make sure the sql statement is not timing out...
Random Solutions
Lock User profile
broadcom netxtreme 57xx gigabit controller
MySql Log error
Restarting the IIS service in Exchange 2003
learning cgi with html variables
Showing content of doc and docx-files directly on web?
SQL server 2000 taking 50% cpu on dual core with SBS windows
how do lI write an "or statement in javascript
Server: Msg 137, Level 15, State 2, Line 9: Must declare the variable '@vriable'.
Generic DNS denied