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; }
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(); }
这个不错
网名:浩秦;
邮箱:root#landv.pw;
博客:landv.cnblogs.com;
只要我能控制一個國家的貨幣發行,我不在乎誰制定法律。金錢一旦作響,壞話隨之戛然而止。