SSRS/c# Problem

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
 
P

Pavel Minaev

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 itto
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 evenif
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";

I'm not a Crystal Reports expert, but why do you set both ReportPath
and ReportEmbeddedResource? MSDN docs on either clearly specify that
when one property is set, the value of the other is ignored. Since
ReportEmbeddedResource is the one you set last, then it looks like
it's the one that's actually used.

In any case, ReportPath should be the path to the file with the
report, and not a directory; and ReportEmbeddedResource should only be
used to load reports that are embedded into an assembly (as the name
clearly indicates), and cannot be a filesystem path.

Try doing this instead of your two lines for ReportPath &
ReportEmbeddedResource:

repView.LocalReport.ReportPath => "C:\\ssrs_test\\Test\\Test\
\report2.rdlc";

And see if that works.
 
M

Michael Kugler

Hi Pavel,

i've tested your advice but it still doesn't work.
now the error message is:
A first chance exception of type
'Microsoft.Reporting.WebForms.MissingReportSourceException' occurred in
Microsoft.ReportViewer.WebForms.dll



Regards,



Michael
 

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