该报告没有表格(DataTable - > Crystal Report)

时间:2015-11-21 14:46:51

标签: c# crystal-reports visual-studio-2015

我是水晶报道的新手。有没有办法添加我对水晶报告数据源的数据表?

我已将此数据表用于datagridview,是否可以将该数据表用作水晶报表的来源?

DataAccess datax = new DataAccess();
DataSet ds = new DataSet("dataset");
DataTable dt = new DataTable();
DataColumn property, minimum, result, maximum, remarks;

    public ReportingForm(string resin_type, string resin_code, string batch_num)
    {
        InitializeComponent();
        datax.initialize();

        AnalysisReport analysis_rep = new AnalysisReport();

        property = new DataColumn();
        minimum = new DataColumn();
        result = new DataColumn();
        maximum = new DataColumn();
        remarks = new DataColumn();

        property.ColumnName = "Property";
        minimum.ColumnName = "Minimum";
        result.ColumnName = "Result";
        maximum.ColumnName = "Maximum";

        dt.Columns.AddRange(new DataColumn[] { property, minimum, result, maximum, remarks });

        initialize_data(resin_type, resin_code, batch_num); //sets the rows

        ds.Tables.Add(dt);

        analysis_rep.SetDataSource(ds.Tables[0]);

        crpt.ReportSource = analysis_rep;
    }
analysis_rep.SetDataSource(ds.Tables[0]);中的

会抛出错误,显示“报告没有表格”

我还尝试了analysis_rep.SetDataSource(dt);,我尝试将数据源设置为数据表,结果相同。

ds.Tables.Count = 1

0 个答案:

没有答案