zoukankan      html  css  js  c++  java
  • 水晶报表,解决——提示“您请求的报表需要更多信息.”

    水晶报表,解决——提示“您请求的报表需要更多信息.”

     string sql = "Select * from Orders";
            string DBConfig_sql = @"Data Source=WAN-9013A0BB35C\SQL2005;Initial Catalog=Northwind;User ID=sa";
            DataSet ds = new DataSet();
            SqlConnection sqlCon = new SqlConnection(DBConfig_sql);
            SqlCommand sqlCmd = new SqlCommand(sql, sqlCon);
            SqlDataAdapter sqlAd = new SqlDataAdapter();
    
            sqlAd.SelectCommand = sqlCmd;
            sqlAd.Fill(ds, "Orders");
    
            CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
            //注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
            CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["Orders"]);
            //{?}中的参数可以不用赋值,即使赋了值也不起作用。
            CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
            CrystalReportSource1.ReportDocument.ParameterFields["Title"].CurrentValues.AddValue("这时推模式的报表样例!");
            CrystalReportSource1.DataBind();
    
            CrystalReportViewer1.ReportSource = CrystalReportSource1;
            CrystalReportViewer1.DataBind();
    
    

           总结:

    连数据库
    填充dataset
    报表查看器获取ReportDocument(报表引擎)对象,从报表抽取数据
    将dataset数据传递给报表引擎

  • 相关阅读:
    7.数组的扩展
    8.对象的扩展
    6.函数的扩展
    5.数值的扩展
    2.变量的解构赋值
    1.let 和 const 命令
    CTE(With As)
    delphi使用ADO在sql数据库存取图片的方法
    使用Razor生成Word
    Redis基础总结
  • 原文地址:https://www.cnblogs.com/tiandi/p/1980413.html
Copyright © 2011-2022 走看看