crystal report - 报告文档不包含setdatasource的定义? [英] crystal report - report document does not contain the definition for setdatasource?

查看:95
本文介绍了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;
}







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

提前谢谢。

解决方案




上面的问题实际上我已经解决了将reportdocument声明为类,并使用其所需的命名空间using CrystalDecisions.CrystalReports.Engine;所以它抛出一个错误。现在我删除了这个类,以便之前的错误飞走了。





感谢所有回复的人。

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.

解决方案

Hi
The above Problem was resolved actually i have declared reportdocument as class as well as used its desired namespace " using CrystalDecisions.CrystalReports.Engine;" so it throws an error.now i removed the class so that previous error flew away.


Thanks for all who responded.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆