Yesterday I wrote that Crystal Reports doesn't recognize a dataview as a datasource. Developers looking to report against dataviews in Crystal must convert the view to a datatable. You can do this in VS2005 through the new DataView.ToTable method. A basic functional equivalent in VS2003 is as follows:
public DataTable ViewToTable(DataView dv)
{
// Create a new table structure from the table object of the view
// then loop through the view and import the rows into the new table
DataTable DtReturn = dv.Table.Clone();
foreach(DataRowView drv in dv)
DtReturn.ImportRow( drv.Row);
return DtReturn;
}
You can plug that into a generic library and use it to create a datatable from a dataview.
On Wednesday thru Friday, I'll cover practical uses of interfaces in the Common Ground Framework for .NET
Peace out...KG
Comments