rdlc

2020年以及过了几天,把之前随性而发的随笔,发布一下,也没太多整理。

https://stackoverflow.com/questions/4652347/dynamically-binding-of-dataset-to-rdlc-reports

 

 

protected void Page_Load(object sender, EventArgs e)
{
    DataSet ds = GetDataSet();
    ReportDataSource rds = new ReportDataSource("Orders", ds.Tables[0]);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(rds);
    ReportViewer1.LocalReport.Refresh();

    GridView1.DataSource = ds;
    GridView1.DataBind();
}

private DataSet GetDataSet()
{
    var conString = ConfigurationManager.ConnectionStrings["dotnetConnectionString"];
    string strConnString = conString.ConnectionString;

    SqlConnection conn = new SqlConnection(strConnString);
    conn.Open();
    string sql = "Select * FROM Orders";

    SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
    DataSet ds = new DataSet();        
    ad.Fill(ds);

    return ds;
}

 https://blogs.msdn.microsoft.com/sqlforum/2011/04/27/walkthrough-assign-dataset-dynamically-created-in-code-to-your-local-report-with-reportviewer/

private void Form1_Load(object sender, EventArgs e)

        {

            SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=AdventureWorksDW2008R2; Integrated Security=True");

            SqlDataAdapter da = new SqlDataAdapter("SELECT ProductCategoryKey, EnglishProductCategoryName FROM DimProductCategory", con);

            DataSet ds = new DataSet();           

            da.Fill(ds);

            ds.Tables[0].TableName = "DataTable1";

           

            this.DataTable1BindingSource.DataSource = ds;

            this.reportViewer1.RefreshReport();

        }

 

这个不错 

https://www.aspsnippets.com/Articles/RDLC-Report-in-Windows-Forms-WinForms-Application-using-C-and-VBNet.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值