In my Windows Forms Application, i want to create a report. i have created an .rdlc file and assigned it a "dummy" dataset as a datasource just to get the schema, as described here :
http://blogs.msdn.com/b/sqlforum/archive/2011/04/28/sql-reporting-services-ssrs-bind-dynamic-dataset-to-your-local-report-with-reportviewer.aspx[
^]
i want to change datasource of my report dynamically in the code. i found many examples like the following:
private DataTable getData()
{
DataSet dss = new DataSet();
string sql = "";
sql = "SELECT ID, CLIENT_ID, AGENT_ID FROM TBLMAILDELETED";
OdbcDataAdapter da = new OdbcDataAdapter(sql, conn);
da.Fill(dss);
DataTable dt = dss.Tables[0];
return dt;
}
private void runRptViewer()
{
this.ReportViewer1.Reset();
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
ReportDataSource rds = new ReportDataSource("dsNewDataSet_Table", getData());
this.ReportViewer1.LocalReport.DataSources.Clear();
this.ReportViewer1.LocalReport.DataSources.Add(rds);
this.ReportViewer1.DataBind();
this.ReportViewer1.LocalReport.Refresh();
}
i want to place similar code on a button click. my question is:
if i want to add a parameter whose value is entered in a textbox on the form, what is the best way to do it?
1- should i add it in code as a parameter in my DataAdapter, and then my query will have a where-clause that uses that parameter to filter results ?
2- should i create ReportParameter and add it to my .rdlc? if so: how will that change the code? and how should that affect my DataAdapter query?
thanks in advance