|
I'm using this below code to create pdf file from ssrs report on button click.It was working fine when i run the project on my local system,but when i hosted it on ISS i'm unable to view the pdf file as o/p.Plz suggest the solution ASAP..
protected void btnAuthenticateAndPrint_Click(object sender, EventArgs args)
{
try
{
LinkButton lb = (LinkButton)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
Label lbOrderID = row.FindControl("lbOrderID") as Label;
int OrderId = Convert.ToInt32(lbOrderID.Text);
da = new SqlDataAdapter("Get_PODetails", con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@MPDI_ID", OrderId);
ds = new DataSet();
da.Fill(ds, "PO");
if (ds.Tables["PO"].Rows.Count > 0)
{
lblPOId.Text=ds.Tables["PO"].Rows[0]["MPDI_ID"].ToString();
lblVendid.Text = ds.Tables["PO"].Rows[0]["MVDI_ID"].ToString();
lblBranch.Text = ds.Tables["PO"].Rows[0]["MBRI_ID"].ToString();
lblDate.Text = Convert.ToDateTime(ds.Tables["PO"].Rows[0]["MPDI_Date"]).ToString("dd-MMM-yyyy");
}
rs = new RSWebService.ReportingService2005();
rsExec = new REWebService.ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
rsExec.Url = "http://localhost/ReportServer/ReportExecution2005.asmx";
byte[] Sendresults = null;
byte[] bytes = null;
string historyID = null;
string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
string format = "PDF";
string encoding = null;
string mimeType = null;
string extension = null;
REWebService.Warning[] warnings = null;
string[] streamIDs = null;
string _reportName = @"/FIMO GOF Assets Reports/GOF PURCHASE ORDER";
REWebService.ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID);
REWebService.ParameterValue[] parameters = new REWebService.ParameterValue[3];
parameters[0] = new REWebService.ParameterValue();
parameters[0].Name = "MVDI_ID";
parameters[0].Value = lblVendid.Text;
parameters[1] = new REWebService.ParameterValue();
parameters[1].Name = "MBRI_ID";
parameters[1].Value = lblBranch.Text;
parameters[2] = new REWebService.ParameterValue();
parameters[2].Name = "MPDI_DocNo";
parameters[2].Value = lblPOId.Text;
rsExec.SetExecutionParameters(parameters, "en-us");
Sendresults = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
MemoryStream ms = new MemoryStream(Sendresults);
FileStream stream = File.Create("Asset Module/Reports/PO_Report.PDF");
stream.Write(Sendresults, 0, Sendresults.Length);
stream.Close();
Label lbpath1 = new Label();
lbpath1.Text = "Reports/PO_Report.PDF";
FileInfo f = new FileInfo(Server.MapPath(lbpath1.Text));
System.Diagnostics.Process.Start(@"" + f.FullName + "");
}
catch (Exception Ex)
{
throw Ex;
}
}
#endregion
modified 23-Dec-12 23:58pm.
|
|
|
|
|
Vinay Meka wrote: working fine when i run the project on my local system,but when i hosted it on ISS i'm unable to
This means something is missing on the server which is present on your localsystem. Files or permission.
Vinay Meka wrote: rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
rsExec.Url = "http://localhost/ReportServer/ReportExecution2005.asmx";
Url expects the local system to have report server. Does the system where you are hosting it has report server installed? It is always good to give proper URL with server name instead of localhost. Like: http://machineServerName/Reportserver
Vinay Meka wrote: FileStream stream = File.Create("Asset Module/Reports/PO_Report.PDF");
You might be having permission error leading to no creation of PDF file.
|
|
|
|