本文介绍了crystal report - 报告文档不包含setdatasource的定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个水晶报告并将数据集绑定到它。一切顺利但我坚持的是在我背后的代码中我在rep.setdatasource附近得到上述错误。

这是我的代码。 (vs2008,net framework 3.5和c#)



  protected   void  Viewbutton_Click( object  sender,EventArgs e)
{
string path = Server.MapPath( @ CrystalReport.rpt) ;
SqlConnection con = new SqlConnection( 数据Source = HOME-PC\\SQLEXPRESS; Initial Catalog = test1; Persist Security Info = True; User ID = user1; Password = user1);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand( select * EMaster,con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, Infotable);
ReportDocument rep = new ReportDocument();
rep.Load((path));
CrystalReportViewer1.RefreshReport();
rep.SetDataSource(ds.Tables [ Infotable]);
// rep.SetDataSource(ds.Tables [0]);
CrystalReportViewer1.ReportSource = rep;
}







任何人都可以找出我的缺点。

提前谢谢。

解决方案

I have created a crystal report and bind the dataset to it.everything goes good but where i'm sticking is in the code behind i'm getting the above error near the "rep.setdatasource".
here is my code. (vs2008 ,net framework 3.5 and c#)

protected void  Viewbutton_Click(object sender, EventArgs e)
            {
                string path = Server.MapPath(@"CrystalReport.rpt");
                SqlConnection con = new SqlConnection("Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=test1;Persist Security Info=True;User ID=user1;Password=user1");
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd = new SqlCommand("select * EMaster", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds, "Infotable");
                ReportDocument rep = new ReportDocument();
                rep.Load((path));
                CrystalReportViewer1.RefreshReport();
                rep.SetDataSource(ds.Tables["Infotable"]);
                //rep.SetDataSource(ds.Tables[0]);
                CrystalReportViewer1.ReportSource = rep;
            }




Can anyone please figure my flaws.
Thanks in advance.

解决方案


这篇关于crystal report - 报告文档不包含setdatasource的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 05:08