M
Michael Kugler
Hi,
I've got some problems using the reporting services from c#. I want to
include a pdf export in my web application..
I've already tried different samples and code snippets but I don't get it to
work. (I don't want to use the web service to get the report from.)
Here is my code. The following internal error occurs: The report definition
for report 'C:\ssrs_test\Test\Test\report2.rdl' has not been specified
is it possibly the data source? Is it necessary to add a data source even if
I have it already set while creating the report?
public void test(HttpResponse MyResponse)
{
Microsoft.Reporting.WebForms.ReportViewer repView = new
Microsoft.Reporting.WebForms.ReportViewer();
LocalReport lr = repView.LocalReport;
repView.Reset();
repView.LocalReport.ReportPath = "C:\\ssrs_test\\Test\\Test";
repView.LocalReport.ReportEmbeddedResource =
"C:\\ssrs_test\\Test\\Test\\report2.rdlc";
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension = "";
try
{
byte[] bytes = lr.Render("PDF", null, out mimeType, out encoding, out
extension, out streamids, out warnings);
MyResponse.Clear();
MyResponse.ContentType = "application/pdf";
MyResponse.AddHeader("Content-disposition", "filename=output.pdf");
MyResponse.OutputStream.Write(bytes, 0, bytes.Length);
MyResponse.OutputStream.Flush();
MyResponse.OutputStream.Close();
MyResponse.Flush();
MyResponse.Close();
}
catch (Exception e)
{
Exception inner = e.InnerException;
while (inner != null)
{
Debug.Print(inner.Message);
inner = inner.InnerException;
}
}
Schöne Grüße
Michael Kugler
I've got some problems using the reporting services from c#. I want to
include a pdf export in my web application..
I've already tried different samples and code snippets but I don't get it to
work. (I don't want to use the web service to get the report from.)
Here is my code. The following internal error occurs: The report definition
for report 'C:\ssrs_test\Test\Test\report2.rdl' has not been specified
is it possibly the data source? Is it necessary to add a data source even if
I have it already set while creating the report?
public void test(HttpResponse MyResponse)
{
Microsoft.Reporting.WebForms.ReportViewer repView = new
Microsoft.Reporting.WebForms.ReportViewer();
LocalReport lr = repView.LocalReport;
repView.Reset();
repView.LocalReport.ReportPath = "C:\\ssrs_test\\Test\\Test";
repView.LocalReport.ReportEmbeddedResource =
"C:\\ssrs_test\\Test\\Test\\report2.rdlc";
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension = "";
try
{
byte[] bytes = lr.Render("PDF", null, out mimeType, out encoding, out
extension, out streamids, out warnings);
MyResponse.Clear();
MyResponse.ContentType = "application/pdf";
MyResponse.AddHeader("Content-disposition", "filename=output.pdf");
MyResponse.OutputStream.Write(bytes, 0, bytes.Length);
MyResponse.OutputStream.Flush();
MyResponse.OutputStream.Close();
MyResponse.Flush();
MyResponse.Close();
}
catch (Exception e)
{
Exception inner = e.InnerException;
while (inner != null)
{
Debug.Print(inner.Message);
inner = inner.InnerException;
}
}
Schöne Grüße
Michael Kugler