日期:2014-05-18  浏览次数:20969 次

水晶报表绑定两个数据表,绑定完成,不显示数据,为什么。
水晶报表里的数据从,链接数据库都一切正常。


下面是代码。
C# code

        private ReportDocument reportDocument;
        private void button13_Click(object sender, EventArgs e)
        {
            ReportDocument _rpt1;
            _rpt1.Load(StartPath + "\\rpt\\HzGBD2.rpt");
            DataSet ds = new DataSet();            
           
            DataTable ds1 = truckDal.GetSqltb(" select TID as 序号,NoteCode as 流水编号,PlateCode as 车牌号, Goods as 货物名称, guige as 规格, Weight as 皮重,GrossWeight as 毛重,NetWeight as 净重 from Table1  where TID = " + int.Parse(label35.Text.Substring(8, label35.Text.Length - 8)) + "");
            DataTable ds2 = truckDal.GetSqltb("select NoteCode as 流水编号,Goods as 货物名称,Guige as 规格,Unit as 单价,Counts as 数量,Price as 金额 from Table2 where NoteCode='" + label35.Text + "'");
            ds.Tables.Add(ds1);
            ds1.TableName = "Table1";
            ds.Tables.Add(ds2);
            ds2.TableName = "Table2";

            ds.Relations.Add(new DataRelation("link", ds1.Columns["流水编号"], ds2.Columns["流水编号"]));
            _rpt1.SetDataSource(ds);

            crystalReportViewer1.ReportSource = _rpt1;
        }



就是不显示数据。为什么

------解决方案--------------------
绑定dataset,sql语句里的字段,要与dataset里的字段相符,不能用中文
------解决方案--------------------
去掉中文,列名和DataSet一致