Use .net object as data source in Crystal Report 2008

后端 未结 1 363
走了就别回头了
走了就别回头了 2021-01-21 13:31

HI all,

I created a .net object (ex: A) which contain data have been collected from tables. Next, i create a List() and pass to

1条回答
  •  醉梦人生
    2021-01-21 14:15

    I had this same error, but encountered it when using an object as the data source for the report. I had the following code:

    var myObj = new MyDataObject();
    cr.Load(@"C:\report.rpt");
    cr.SetDataSource(myObj);
    

    and got the same error.

    Changing the SetDataSource line to this:

    cr.SetDataSource(new [] { myObj });
    

    helped and it is now working correctly. In other words, try wrapping your object in an array. If you're using a list, try converting it to an array first (use the .ToArray() method).

    0 讨论(0)
提交回复
热议问题