日期:2014-05-19  浏览次数:21048 次

报表加载失败
SqlConnection   conn   =   new   SqlConnection();
                        conn.ConnectionString   =   "data   source=192.168.117.26;initial   catalog=dlerp_6;user   id=itx6;password=05251145;persist   security   info=True ";
                        conn.Open();

                        ReportDocument   rptMain   =   new   ReportDocument();
                        SqlCommand   cmd   =   new   SqlCommand();
                        cmd.Connection   =   conn;
                        cmd.CommandType   =   CommandType.StoredProcedure;
                        cmd.CommandText   =   "pro_stockOrderPrint ";
                        rptMain.FileName   =   Application.StartupPath   +   @ "\Report\CryStockOrder.rpt ";
                        SqlDataAdapter   da   =   new   SqlDataAdapter(cmd.CommandText,   conn);
                        DataSet   ds   =   new   DataSet();
                        da.Fill(ds,   "table ");

                        rptMain.SetDataSource(da);//报表加载失败
                        this.crystalReportViewer1.ReportSource   =   rptMain;
                        conn.Close();

请问为什么在上面的地方会出现报表加载失败呢?

------解决方案--------------------
兄台,你做的是C/S的报表吗,可以把源码发我吗?
------解决方案--------------------
rptMain.SetDataSource(da);//报表加载失败

改为
rptMain.SetDataSource(ds.Table[ "table "]);
试试

------解决方案--------------------
rptMain.SetDataSource(ds);//报表加载失败//绑定的是ds不是da.
this.crystalReportViewer1.ReportSource = rptMain;
conn.Close();

------解决方案--------------------
嗯.谢谢
------解决方案--------------------
我不懂做报表,你可以把整个源码发我吗?
我的邮件是jiangnengbin@126.com
------解决方案--------------------
我以前从来没有做过.好晕呀.现在要做,都不知道怎么做!
------解决方案--------------------
xiaowengang(海岛)
你的QQ是好多,我的是250700947请加我好吗?
------解决方案--------------------
查看一下你的数据源,是否连接到数据库中的存储过程,我也再弄这个东西,一条条sql查没问题,加上存储过程就出问题了。
------解决方案--------------------
楼上这位仁兄,可以加我的QQ吗?
------解决方案--------------------
只能用数据表做为参数,不能用数据集作参数!