开发者

Can crystal reports get data from an object data source?

开发者 https://www.devze.com 2023-01-20 09:11 出处:网络
Can crystal reports get data from an object data source instead of a database? I am using the crystal reports that comes with vs2008. I am coding in c# 3.5.

Can crystal reports get data from an object data source instead of a database? I am using the crystal reports that comes with vs2008. I am coding in c# 3.5.

I would like to use an object data source that returns a List< MyClass>.

For when we migrate to ssrs in the future, Can ssrs 2008 get data from 开发者_如何学Pythonthis object data source ?


SetDataSource has an overload excepting ICollection parameters. Using it, you can bind simple collections of objects to CR. But this isn't that flexible than using data sets. With data sets you can bind multiple related tables and build reports of a higher complexity.

The migration of your server has no impact on CR, because SetDataSource only works with disconnected objects such as data sets or object data sources.


Yes you can do that, but you have to wrap the objects in an array :

// my crystal report
Rpt rpt = new Rpt();


AirLine lAirLine = (AirLine)cmbAirLine.SelectedItem;

// I added two objects as datasources in report designer

// here aWB.AWBPieceList is List<AWBPiece> where 'AWBPiece' is some class.
rpt.Database.Tables[0].SetDataSource( AWBPieceList.ToArray() );

// the second : objects are mapped to tables by crystal report.
rpt.Database.Tables[1].SetDataSource( new AirLine[] { lAirLine } );
0

精彩评论

暂无评论...
验证码 换一张
取 消