4,819
社区成员




if {?Pm-Dictionary.DICTNAME} = '技术类' then
'10051001'
else if {?Pm-Dictionary.DICTNAME} = '产品类' then
'10051002'
string ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\Database1.mdb"; //我这边以Access数据库进行测试,其他数据库同理
OleDbConnection conn = new OleDbConnection(ConnString);
string strSQL = "select DISTINCT DICTNO,DICTNAME,COLNAME from (select DICTNAME,DICTNO,a.COLNAME from dictionary a union all select a.DICTNAME,b.DICTNO,a.COLNAME from dictionary a inner join dictionary b on a.DICTNO=b.COLNAME union all select a.DICTNAME,c.DICTNO,a.COLNAME from (dictionary a inner join dictionary b on a.DICTNO=b.COLNAME) inner join dictionary c on b.DICTNO=c.COLNAME) t1 left join TableA t2 on t1.DICTNO=t2.science"; //查询出TableA中science的所有所属类型
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, conn);
DataSet1 ds = new DataSet1();
da.Fill(ds.Dictionary); //填充到数据集DataSet1的Dictionary表
strSQL = "select * from TableA";
da = new OleDbDataAdapter(strSQL, conn);
da.Fill(ds.TableA); //填充到数据集DataSet1的TableA表
CrystalReport1 myReport = new CrystalReport1();
myReport.SetDataSource(ds); //为报表设置数据源
crystalReportViewer1.ReportSource = myReport;