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

An error has occured while resolving ObjectDataSource1 data source: cannot convert to type System.Int32

2 Answers 510 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 1
Kenneth asked on 09 Apr 2014, 06:11 PM
Q1 2014 silverlight

I am using the ObjectDataSource with a business object with this signature:

Public Class TransferReportClass
    <DataObjectMethod(DataObjectMethodType.Select)> _
    Public Function TransferReportList(ByVal sn As String, _
                                       ByVal transferBy As Integer, _
                                       ByVal sortBy As Short, _
                                       ByVal allDates As Boolean, _
                                       ByVal FromDate As Date, _
                                       ByVal ToDate As Date, _
                                       ByVal direction As Short) As List(Of DataTransfer)

If I initialize the parameters in the configure data source wizard the report runs fine.
However I want to pass the paramenters at run time so in RenderBegin I do this:

        args.ParameterValues("sn") = Application.Current.Resources("sn")
        args.ParameterValues("transferBy") = rp.transferBy
        args.ParameterValues("sortBy") = rp.sortBy
        args.ParameterValues("allDates") = rp.allDates
        args.ParameterValues("FromDate") = rp.FromDate
        args.ParameterValues("ToDate") = rp.ToDate
        args.ParameterValues("direction") = rp.direction

When I was rusing a data method that returned a dataset instead of a list as above the report worked fine.
I changed it to return a list of my data bojects becuase I need to do some formating and the class already
handles everything.

when I run the report now I get the following error:

An error has occured while processing Report 'TransferReport':
An error has occured while resolving ObjectDataSource1 data source: cannot convert to type System.Int32

It must be talking about the parameters, so I modified the methods signature in an attempt to appeaise it,
I changed Interger to Int32, Shoert to Int16, and Date to Datetime, with no effect.

2 Answers, 1 is accepted

Sort by
0
Kenneth
Top achievements
Rank 1
answered on 09 Apr 2014, 06:53 PM
Resolved.

OK, this was my fault for being a newbie, I failed to create parameters for the report, when I went through the configure data source wizard it showed the parameters for the dats method and that made me think the report parameters were added, they were not.  Once I added them I still had the error, but then somehow figured I needed to re-configure the datasource and this time tell it where to get the values for each parameter, that is, =Parameters.xx.Value.

Learning curve.

0
Stef
Telerik team
answered on 11 Apr 2014, 01:53 PM
Hi Ken,

We are glad to hear you have resolved the issue.

Some additional information that may be helpful for you when you use custom methods is about the types of report parameters and how they are recognized by the expression engine: ReportParameterType Enumeration.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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