本文介绍了在DataSet中有多个表格时,在水晶报表中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 10的Crystal Report,



我已经添加了DataSet。



现在如果有DataSet中只有一个表,然后显示数据,而如果我使用链接添加两个表,那么数据不会被显示。



我正在从该表中获取字段的数据集(XSD)。



如何克服这个问题。



感谢提前。
Khilen

解决方案

我以前做的是;


  1. 将2个数据集添加到crstal报告。

  2. 以下代码将2个数据集变成同一报告。

C#

  public partial class Default2:System.Web.UI.Page 
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings [MyCtr1]。ConnectionString);
SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings [MyCtr2]。ConnectionString);
ReportDocument rdoc = new ReportDocument();
DataTable ds = new DataTable();
DataTable ds1 = new DataTable();
protected void Page_Load(object sender,EventArgs e)
{

if(!IsPostBack)
{

loadreport();
}

private void loadreport()
{
{
cn.Open();
SqlDataAdapter da = new SqlDataAdapter(select * from [MyTable1] where(Number LIKE'+ DropDownList1.Text +'),cn);
da.Fill(ds);
cn.Close();
{
{
cn1.Open();
SqlDataAdapter da1 = new SqlDataAdapter(select * from [MyTable2] where(No LIKE'+ DropDownList1.Text +'),cn1);
// DataTable ds1 = new DataTable();
da1.Fill(ds1);
cn1.Close();
}
rdoc.Database.Tables [0] .SetDataSource(ds);
rdoc.Database.Tables [1] .SetDataSource(ds1);

InvoiceReport.ReportSource = rdoc;
InvoiceReport.DataBind();
}


I am using Crystal Report with VS 10,

I have added DataSet.

Now if There's only One Table in DataSet then data is being displayed, while if i add Two Tables with Link, then Data is not being display.

And i am taking fields from this table of DataSet(XSD).

How to overcome this problem.

Thanks In Advance.Khilen

解决方案

What I'm used to do is ;

  1. add 2 dataset to crstal report.
  2. Below code for blinding 2 dataset into same report.

C#

  public partial class Default2 : System.Web.UI.Page
{
    SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCtr1"].ConnectionString);
    SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCtr2"].ConnectionString);
    ReportDocument rdoc = new ReportDocument();
    DataTable ds = new DataTable();
    DataTable ds1 = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            loadreport();
            }

  private void loadreport()
{
{              
        cn.Open();
        SqlDataAdapter da = new SqlDataAdapter("select *  from [MyTable1] where (Number LIKE '" + DropDownList1.Text + "') ", cn);
       da.Fill(ds);
       cn.Close();
{
{
       cn1.Open();
       SqlDataAdapter da1 = new SqlDataAdapter("select *  from [MyTable2] where (No LIKE '" + DropDownList1.Text + "') ", cn1);
            //DataTable ds1 = new DataTable();
        da1.Fill(ds1);
     cn1.Close();
}
    rdoc.Database.Tables[0].SetDataSource(ds);
    rdoc.Database.Tables[1].SetDataSource(ds1);

    InvoiceReport.ReportSource = rdoc;
    InvoiceReport.DataBind();
}

这篇关于在DataSet中有多个表格时,在水晶报表中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 01:26