This is a migrated thread and some comments may be shown as answers.

GUID as String Parameter passed as Null

1 Answer 330 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 20 Feb 2014, 03:11 PM
When I pass a parameter through, for use in the Select statement of a SQL Datasource, it gets passed as Null, even though it appears correctly when I set the parameter to visible (for testing).

The parameter is a Guid which I convert to a string before passing and then convert back to a Guid in the Select statement.

If I remove the Where clause in the Select statement, its fine.

I am using version 7.2.1.4.127 and have run the upgrade wizard. I have tried putting single quotes around the Guid.

I pass the parameter as follows:

Model
        public TypeReportSource ReportSource
        {
            get
            {
                TypeReportSource reportSource = new TypeReportSource { TypeName = "AcumenSynergy.Reporting.PurchaseOrderLinesOutstanding, AcumenSynergy.Reporting"};
                reportSource.Parameters.Add("ProjectID", this.SelectedProjectID.ToString());
                return reportSource;
            }


View
<div id="projectIDSelector">
    @Html.LabelFor(model => model.SelectedProjectID)
    @Html.DropDownListFor(model => model.SelectedProjectID, Model.ProjectItems, new { id = "projectID", title = "Select the Project" })
</div>


@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
            .ServiceUrl("/Reporting/api/Reports/")
            .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
                        .ReportSource(Model.ReportSource)
        .ViewMode(ViewModes.INTERACTIVE)
        .ScaleMode(ScaleModes.SPECIFIC)
        .Scale(1.0)
        .PersistSession(false)
)

<script>
$('#projectID').change(function () {
    var viewer = $("#reportViewer1").data("telerik_ReportViewer");
    viewer.reportSource({
        report: viewer.reportSource().report,
        parameters: { ProjectID: $(this).val() }
    });
    console.log($(this).val());
    viewer.refreshReport();
});
</script>


Select Statement in SQL Data Source
Select * from dbo.Projects  where ProjectID = (SELECT Convert(uniqueidentifier,@ProjectID)) 




1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 21 Feb 2014, 05:19 PM
Hi Chris,

This is a quote from your ticket on the same topic:

"Using the code snippets from your forum post I created the attached sample project, and there are no issues loading data based on uniqueidentifier column. Note you can use string directly in the SQL query e.g.:
where rowguid like '7D3FD384-4F29-484B-86FA-4206E276FE58'
Please verify the query returns records with the selected value.

Test displaying the report with other report viewer, e.g. Windows Forms ReportViewer, and if the report is displayed correctly check if Newtosoft.Json.dll is installed in the GAC of the machine, and remove it from there. Then update the reference in the project using Json Nuget package
."

Let us continue the discussion in your ticket, until it is resolved. Finally we can update the forum thread with the result.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or