本文介绍了如何在一个水晶报告中显示多个表格中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有2张桌子销售& sale1我想在一个水晶报告中显示这两个表的数据。
There are 2 tables sale & sale1 I want to display data from these two table in one crystal report.
DataReportClass dr = new DataReportClass();
DataView dview1 = new DataView();
sale s = new sale();
String qry, tname = "sale",tname1="sale1";
//form load
private void rpt_sale_Load(object sender, EventArgs e)
{
dview1.Table = dr.LoadReport1(tname,tname1).Tables["Temp"];
s.SetDataSource(dview1);
crystalReportViewer1.ReportSource = s;
}
//This code is in my .class file
public DataSet LoadReport1(String tablename,String tbl)
{
qry = "Select * from " + tablename + ","+tbl+"";
ds = db.search(qry);
//db is object of my another .class file includes connection string
return ds;
}
public DataSet search(String s)
{
try
{
SqlDataAdapter da = new SqlDataAdapter(s, conn);
DataSet ds = new DataSet();
da.Fill(ds, "Temp");
return ds;
}
catch(Exception ex)
{
throw ex;
}
}
推荐答案
这篇关于如何在一个水晶报告中显示多个表格中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!