Dear All,
I am facing problem in binding the dynamic datasets to the RDLC report (report present in my ASP.NET web application).
I am aware of the process of creating the RDL in Business Intelligence SSRS project. But in that case we already know what data that we are going to put into the report.
But in my case, I am not aware of what columns/tables/data that I might get from the Dataset. There is a dynamic sql that will be constructed depending on various business rules and my Job is to bind the data that I get from the dynamic query into a SSRS report.
I am using the below code but when I run the page, the report is showing empty. I have taken a simple query "Select MemberId, PSAID, Name FROM Members" for testing purpose.
ASPX Code :
<div><rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="600px" Width="800px"><LocalReport ReportPath="SampleReport.rdlc" ><DataSources><rsweb:ReportDataSource /></DataSources></LocalReport></rsweb:ReportViewer></div>
ASPX.CS Code:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataSet ds = GetDataSet(); ReportDataSource rds = new ReportDataSource(); ReportViewer1.Reset(); rds.Value = ds.Tables[0]; ; rds.Name = "MemberTable"; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SampleReport.rdlc"); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.Refresh(); } } private DataSet GetDataSet() { if (sqlConn.ConnectionString != null && sqlConn.ConnectionString.Trim() != "" && sqlConn.ConnectionString.Trim() != string.Empty) { sqlConn = (SqlConnection)Session["Connection"]; } else { da_mgr = new data_access_manager(); Session["ConnectionString"] = ConfigurationManager.ConnectionStrings["partialConnectString"]; sqlConn = da_mgr.Connect(Session["ConnectionString"].ToString()); } string sql = "Select MemberId, PSAID, Name FROM Members"; SqlDataAdapter ad = new SqlDataAdapter(sql, sqlConn); DataSet ds = new DataSet(); ad.Fill(ds,"MemberTable"); return ds; }
I have added a blank RDLC file "SampleReport.rdlc" file into my web project.
All I need is to show the data returned from "Select MemberId, PSAID, Name FROM Members" SQL on the SSRS report.
Please do let me know your thoughts.