zoukankan      html  css  js  c++  java
  • Push模式

    WEB方式下】
     
    using CrystalDecisions.Shared;
    using CrystalDecisions.CrystalReports.Engine;
    using System.Data.SqlClient;
           protected void Button_push_Click(object sender, EventArgs e)
        {
            string sql = "SELECT T1, T2, T3 FROM T where T1='a'";
            string DBConfig_sql =@"Data Source=SYWZSWL\SQLEXPRESS;Initial Catalog=Test;User ID=sa;Password=123456";
            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, "sql");
            CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));  
            //注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
    CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["sql"]);
    //{?}中的参数可以不用赋值,即使赋了值也不起作用。
           // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
            CrystalReportSource1.ReportDocument.ParameterFields["Title"].CurrentValues.AddValue("这时推模式的报表样例!");
            CrystalReportSource1.DataBind();
     
            CrystalReportViewer1.ReportSource = CrystalReportSource1;
            CrystalReportViewer1.DataBind();
        }
     
    //////
    【WEB方式下】

    using CrystalDecisions.Shared;
    using CrystalDecisions.CrystalReports.Engine;
    using System.Data.SqlClient;
    protected void Button_push_Click(object sender, EventArgs e)
    {
    string sql = "SELECT T1, T2, T3 FROM T where T1='a'";
    string DBConfig_sql =@"Data Source=SYWZSWL\SQLEXPRESS;Initial Catalog= Test;UserID=sa;Password=123456";
    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, "sql");
    CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
    //注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
    CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["sql"]);
    //{?}中的参数可以不用赋值,即使赋了值也不起作用。
    // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
    CrystalReportSource1.ReportDocument.ParameterFields["Title"].CurrentValues.AddValue("这时推模式的报表样例!");
    CrystalReportSource1.DataBind();

    CrystalReportViewer1.ReportSource = CrystalReportSource1;
    CrystalReportViewer1.DataBind();
    }
     
     
    【FORM方式下】
     private void Form1_Load(object sender, EventArgs e)
            {
                //推模式
                string sql = "SELECT T1, T2, T3 FROM T where T1='a'";
                string DBConfig_sql = @"Data Source=SYWZSWL\SQLEXPRESS;Initial Catalog=Test;User ID=sa;Password=123456";
                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, "sql");
                crystalReport1.Load(Application.StartupPath + "CrystalReport.rpt");
                crystalReport1.SetDataSource(ds.Tables["sql"]);
    //{?}中的参数可以不用赋值,即使赋了值也不起作用。
                // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
                crystalReport1.ParameterFields["Title"].CurrentValues.AddValue("这时推模式的报表样例!");
     
                crystalReportViewer1.ReportSource = crystalReport1;
    }
     
     
    /////
    【FORM方式下】
    private void Form1_Load(object sender, EventArgs e)
    {
    //推模式
    string sql = "SELECT T1, T2, T3 FROM T where T1='a'";
    string DBConfig_sql = @"Data Source=SYWZSWL\SQLEXPRESS;Initial Catalog= Test;UserID=sa;Password=123456";
    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, "sql");
    crystalReport1.Load(Application.StartupPath + "CrystalReport.rpt");
    crystalReport1.SetDataSource(ds.Tables["sql"]);
    //{?}中的参数可以不用赋值,即使赋了值也不起作用。
    // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
    crystalReport1.ParameterFields["Title"].CurrentValues.AddValue("这时推模式的报表样例!");

    crystalReportViewer1.ReportSource = crystalReport1;
    }
  • 相关阅读:
    [摘抄]数据湖,大数据的下一个变革
    linux localhost 借助nginx 支持https
    mac os 下 android studio 选择模拟器设备的时候一直显示Loading
    SpringBoot 项目遇到错误: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    nexus-2.12.0-01 shiro漏洞升级
    IDEA 历史版本下载地址
    Postfix 554 5.7.1 Relay Access Denied
    Java SPI 机制实现项目框架高扩展性
    IDEA控制台 springboot输出中文乱码
    Setup Apache2 in Debian 9 and enable two ports for two sites
  • 原文地址:https://www.cnblogs.com/chenbg2001/p/1515262.html
Copyright © 2011-2022 走看看