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

SQL code works in vs2012 NOT in Telerik Reporting

2 Answers 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
andy
Top achievements
Rank 1
andy asked on 12 May 2015, 04:51 PM

Hi,

I am trying to do some simple math for a report and it works fine in vs2012 and in the Telerik Reporting SQLDataSource when I execute the query.

However I cannot access the results because the Data Explores gives me the following error.

System.Data.SqlClient.SqlException (0x80131904): Operand data type nvarchar is invalid for subtract operator.

Here is the code:

SELECT
  CASE
    WHEN (@RowsTotal IS NULL OR
      @RowsTotal = 0) THEN 0
    ELSE ((@Rows1 + @Rows2 + @Rows4) * 1.0/ (@RowsTotal - @Rows8)) * 1.0
  END AS 'Permanency Discharges %'
, CASE
    WHEN (@RowsTotal IS NULL OR
      @RowsTotal = 0) THEN 0
    ELSE ((@Rows6 + @Rows7) *1.0 / (@RowsTotal) *1.0)
  END AS 'Insufficient Resources %'

All of the variables are initiated as a float in SQL but as a double in Telerik Reporting.

The values of the variables are:

@Rows1 = 5

@Rows2 = 11

@Rows4 = 12

@Rows6 = 2

@Rows7 = 7

@Rows8 = 2

@RowsTotal = 47

If I replace the variables in the SQL with their values it works in Telerik Reporting.

Any help is greatly appreciated.

Andy

2 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 14 May 2015, 12:16 PM
Hi Andy,

The attached TRDX file uses the stored procedure from your code snippet. The report settings can be previewed in the Standalone Designer of Telerik Reporting Q1 2015 SP1.
Please  check how SQL parameters are mapped to report parameters, where the type of the SQL parameter is specified - SqlDataSource Wizard (step 4).

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
andy
Top achievements
Rank 1
answered on 18 May 2015, 05:05 PM

Thanks

I'll check it out.  The report does work when I do the math in the report instead of SQL.

Andy

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