前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

rdlc

作者头像
landv
发布2020-02-11 11:45:05
6570
发布2020-02-11 11:45:05
举报
文章被收录于专栏:landv

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

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

代码语言:javascript
复制
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/

代码语言:javascript
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-01-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档