Hi ,How to get data from object source to report viewer..
Hi,i am developing one application .In that for value in list box i m getting using object source.I need to compare these object source data to data and get the result into reportviewer ..I doing mistake some where .i m placing the code below ..pleas uggest some solution.
i have a list box and a button .i placing the button click event code here...to get data into list box i m using object source..
string thisConnectionString =
ConfigurationManager.ConnectionStrings[
"DatabaseConnectionString"].ConnectionString;
string strddl = ObjectDataSource1.ToString();
SqlConnection Con = new SqlConnection(thisConnectionString);
SqlCommand Cmd = new SqlCommand("select * from table3 where [col1] ='" + strddl + "'", Con);
SqlDataAdapter da = new SqlDataAdapter(Cmd);
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
ReportDataSource datasource = new ReportDataSource("DatabaseDataSet_table3", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
if (ds.Tables[0].Rows.Count == 0)
{
// lblMessage.Text = "Sorry, no data under this category!";
}
ReportViewer1.LocalReport.Refresh();