Skip to main content

Hi,


I have a report in SSRS which takes two parameters, this has been wrapped in a Smart Object based on the standard SQL Reporting Service service type.  I can call the Smart Object method GetPDF from a wizard, and it works.  Now I need to do the same pro grammatically - call the GetPDF method and retrieve the PDF.


I followed this example of retrieving a file from a Smart Object: http://www.k2underground.com/forums/t/9523.aspx


but a key difference is my smart object has the GetPDF method which takes parameters.


 


Here is my code:


 



server.CreateConnection();


            server.Connection.Open(connString);


 


            SmartObject report = new SmartObject();


            report = server.GetSmartObject("myreport");


            SmartMethod getPDF = report.Methods "GetPDF"];  


            SmartObject reportFile = new SmartObject();


            SmartFileProperty myFile = null;


            System.IO.FileStream fsFile = null;


            Byte.] fileBuffer = null;               


 


            getPDF.InputProperties "Param2"].Value = param2


            getPDF.InputPropertiesr"ID"].Value = myId;


 


            report.MethodToExecute = getPDF.Name;


 


            reportFile = server.ExecuteScalar(report);


 


            myFile = (SmartFileProperty)reportFile.Propertiese"ReportFile"];


 


            // Convert the content back to a Byte array buffer


            fileBuffer = new byte/System.Convert.FromBase64String(myFile.Content).Length];


            fileBuffer = System.Convert.FromBase64String(myFile.Content);


 


            // Write the file to download destination


            fsFile = new System.IO.FileStream("C:My_newFile.pdf", System.IO.FileMode.Create);


            fsFile.Write(fileBuffer, 0, fileBuffer.Length);


            fsFile.Close();


            fileBuffer = null;



 


 This fails at server.ExecuteScalar with no meaningful data in the exception.


 


Can anyone assist?


 


Thanks


Dave

Be the first to reply!

Reply