一使用视图meeting将多表关联整合在一起
二通过Sql语句筛选数据
三建立和主从表的关联
四注意在CrystalReport表中插入子报表的时候一定要将主从表的关联字段设置好否则出乱子
主体代码如下
/// ///BindCrystalReport
///
///
sql
privatevoidbdReport(stringstrS)
{
oCR=newCrystalReport();
SqlConnectioncnn=newSqlConnection(ConfigurationSettingsAppSettings[ConnectionSqlServer]);
SqlDataAdaptercmd=newSqlDataAdapter(strScnn);
//CreateandfilltheDataSet
DataSetds=newDataSet();
cmdFill(dsmeeting);
//SqlDataAdaptercmd=newSqlDataAdapter(select*fromrealplanwhererplanidin(selecttopplanidfrom(+sqlStr+)asaorderbyplanid)cnn);
SqlDataAdaptercmd=newSqlDataAdapter(SqlIsOpercnn);
cmdFill(dsrealplan);
//CreatetherelationbetweentheAuthorsandTitlestables
dsRelationsAdd(mo
dsTables[meeting]Columns[planid]
dsTables[realplan]Columns[rplanid]);
//bindingreportViewer
oCRSetDataSource(ds);
thisCrystalReportViewerReportSource=oCR;
//Closetheconnection
cnnClose();
}