Friday, March 23, 2012

How can i pass GUID as sqlreport input paramater?

Hi,
How can I pass GUID as sqlreport Input parameter? I get the following error -

"Failed to convert parameter value from a String to a Guid. (System.Data)"

I also tried passing guid within the curly braces but of now use. Please help!
Ashu

Try creating a ReportParameter object and then storing the GUID, as a string, inside this parameter.

Example:

Microsoft.Reporting.Winforms.ReportParameter tempParameter = new Microsoft.Reporting.Winforms.ReportParameter();

tempParameter = new Microsoft.Reporting.Winforms.ReportParameter("ID", GUID.ToString());

Finally, pass this ReportParameter object to the report.

Example:

reportViewer.LocalReport.SetParameters(tempParameter);

No comments:

Post a Comment