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;
    }
  • 相关阅读:
    H.264---(I、P、B帧)(I帧和IDR帧)(DTS和PTS、time_base)
    H.264---帧内预测编码和帧间预测编码
    H.264---编码架构分析
    视频编码技术---可分级视频编码
    Linux 进程通信
    mac 下使用 git && SourceTree
    mac 下安装 mongodb,Robommongodb
    mac 下 nginx的安装
    VPD(Virtual Private Database) 简单演示
    connect by prior start with
  • 原文地址:https://www.cnblogs.com/chenbg2001/p/1515262.html
Copyright © 2011-2022 走看看