问题: 我要用C#来控制水晶报表里面的参数,也就是说不是报表做出来的时候就进行数据绑定的,是通过C#动态进行数据绑定的,听说VS.NET下面的安装目录有实例代码,但是我不知道放在那里了,谁要知道路径告诉我下也可以,
这是国际紧急求救,谁知道麻烦回帖(告诉我路径),或加QQ804206885 写明水晶报表   
HELP NOW   再线等   本人不是特别笨,给个DEMO我一看  即可  ,立刻给分结贴  谢谢
再次声明是国际求救  HELP!!!!

解决方案 »

  1.   

    http://topic.csdn.net/u/20090713/18/6e14bf28-1979-4ade-9c60-aaf09284553d.html?seed=324319934&r=58509768#r_58509768这里有,阿泰大神做的很全面的
      

  2.   

    呵呵 错了 我有一套他们的 代码, 和微软mvp的视频。
      

  3.   

    VS安装目录的 Crystal Reports\Samples 目录下
      

  4.   

    VS05的话搜下安装目录下的 TutorialSample 的安装文件,安装后会有更多的示例
      

  5.   

    谢谢大家  微软那个邵志东的视频我看过了  但是我没太明白 push模式 
    那个dataset是强制类型,要用代码直接写怎么办?   还有就是 如果说参数和绑定的东西都有该怎么混合弄?
      

  6.   

    push  模式难道   必须要在报表中直接定义吗?  如果说我的数据库是远程连接的   那么我在生成报表的时候需要把连接IP写死吗?    怎么处理这个部分? Q804206885
      

  7.   

    这个还是问阿泰版主去吧, 这个给你参考一下C# WinForm开发系列 - Crystal Report
      

  8.   

    Push模式,建议还是去看下阿泰的文章好了
    下面是我举的一个例子的代码部分namespace reportTest
    {
        public partial class _Default : System.Web.UI.Page
    {
        //绑定水晶报表
            private void Page_Init(object sender, EventArgs e)
            {
                FillDropDownList();
                SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
                con.Open();
                string strSql = "SELECT * FROM Color";
                SqlDataAdapter da = new SqlDataAdapter(strSql, con);
                DataSetT ds = new DataSetT();
                da.Fill(ds, "color");
                con.Close();            ReportDocument rd = new ReportDocument();
                rd.Load(Server.MapPath("CrystalReport1.rpt"));
                rd.SetDataSource(ds);
                this.CrystalReportViewer1.ReportSource = rd;
            }//绑定下拉菜单
            public void FillDropDownList()
            {
                SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
                con.Open();
                string strSql = "SELECT [type] FROM Color GROUP BY [type]";
                SqlCommand com = new SqlCommand(strSql, con);
                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    ddlType.Items.Add(dr[0].ToString().Trim());
                }
                dr.Close();
                con.Close();
            }//搜索按钮
            protected void btnLoad_Click(object sender, EventArgs e) 
            {
                SqlConnection con = new SqlConnection("Server=CHONG5;uid=sa;pwd=WXB94#gift;database=StoneERP");
                con.Open();
                string strSql = "SELECT * FROM Color WHERE [Type] = '" + ddlType.SelectedValue.Trim() + "'";
                SqlDataAdapter sda = new SqlDataAdapter(strSql, con);
                DataSetT ds = new DataSetT();
                sda.Fill(ds, "color");
                con.Close();
                ReportDocument rd = new ReportDocument();
                rd.Load(Server.MapPath("CrystalReport1.rpt"));
                rd.SetDataSource(ds);
                this.CrystalReportViewer1.ReportSource = rd;
            }
        }
    }DataSetT为数据集
      

  9.   

    帮忙顶一下,我现在也在研究水晶报表,也是用的push,模式下面我是我项目的部分代码,第一次打开的时候,速度有点慢,而且要求水晶报表设计好了才可以
      m_strpath = Application.StartupPath;//获取系统的运行路径            logOnInfo = new TableLogOnInfo();            ReportDocument crystalReport1 = new ReportDocument();
                crystalReport1.Load("水晶报表文件");
                           logOnInfo.ConnectionInfo.ServerName ="serverName"            logOnInfo.ConnectionInfo.DatabaseName = "数据库名称"            logOnInfo.ConnectionInfo.UserID ="用户"            
    logOnInfo.ConnectionInfo.Password =“口令”            
    crystalReport1.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
                crystalReport1.SetDataSource(mTable);//datatable
                crystalReportViewer1.ReportSource = crystalReport1;
    不知道有没有用处,供你参考,就是速度有点慢
      

  10.   

    private void btnPush_Click(object sender, EventArgs e)
            {//push模式
                CrystalReport1 newReport = new CrystalReport1();
                string sql = "select * from student";
                string strCon = "Data Source=.;Initial Catalog=studentManage;Integrated Security=True";
                SqlConnection con = new SqlConnection(strCon);
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter(sql, strCon);
                DataSet ds = new DataSet();
                sda.Fill(ds, "students");
                con.Close();            string strPath = Application.StartupPath;
                strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
                strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
                strPath += @"\\CrystalReport1.rpt";            //repDoc.Load(strPath);
                //repDoc.SetDataSource(ds.Tables["myWaiters"]);
                newReport.Load(strPath);
                newReport.SetDataSource(ds.Tables["students"]);
                newReport.Refresh();
                crOrder.ReportSource = newReport;
                
                
            }        private void btnPull_Click(object sender, EventArgs e)
            {//pull模式
                string strPath = Application.StartupPath;
                strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
                strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
                strPath += @"\\CrystalReport1.rpt";
                
                repDoc.Load(strPath);
                repDoc.Refresh();
                
                //repDoc.SetParameterValue("Title", "这是推模式的一个测试表!");
                //repDoc.SetParameterValue("Parm", 1);            crOrder.ReportSource = repDoc;   
                           
            }
      

  11.   

    我这里有个push和pull的报表。要的话发给你。
      

  12.   

    推模式,直接将DataSet赋值过去就ok了啊