Mycombobox name = cmbsummary private void cmbsummary_SelectedIndexChanged(object sender, EventArgs e) { string strQry; SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["TrafficDB"]); strQry = "Select FileID ,Sitecode from TBL_TXN_MAIN order by Sitecode"; SqlCommand objCmdVtype = new SqlCommand(strQry, objConn); SqlDataAdapter objDAVtype = new SqlDataAdapter(objCmdVtype); DataSet dsVtype = new DataSet(); objDAVtype.Fill(dsVtype, "dtVtype"); cmbsummary.DataSource = dsVtype.Tables["dtVtype"]; cmbsummary.DisplayMember = "Sitecode"; cmbsummary.ValueMember = "FileID"; dsVtype.Dispose(); } private void cmbtypesummary_click(object sender, EventArgs e)------Filling data in this code { string strQry; SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["TrafficDB"]); strQry = "Select FileID ,Sitecode from TBL_TXN_MAIN order by Sitecode"; SqlCommand objCmdVtype = new SqlCommand(strQry, objConn); SqlDataAdapter objDAVtype = new SqlDataAdapter(objCmdVtype); DataSet dsVtype = new DataSet(); objDAVtype.Fill(dsVtype, "dtVtype"); cmbtypesummary.DataSource = dsVtype.Tables["dtVtype"]; cmbtypesummary.DisplayMember = "Sitecode"; cmbtypesummary.ValueMember = "FileID"; dsVtype.Dispose(); } private void SiteSummary()---------- Sitesummary code { try { rpSiteSummary objRpt; objRpt = new rpSiteSummary(); SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["TrafficDB"]); String strQry = string.Empty; strQry = "Select Sitecode,count(1) Total from TBL_TXN_MAIN where Sitecode =(cmbsummary.text)group by Sitecode"; // Pls check this query. .. SqlDataAdapter adapter = new SqlDataAdapter(strQry, myConnection); DataSet Ds = new DataSet(); adapter.Fill(Ds, "DTSiteSummary"); //if (Ds.Tables[0].Rows.Count == 0) //{ // return; //} objRpt.SetDataSource(Ds); frmReports reportsform = new frmReports(); reportsform.crystalReportViewer.ReportSource = objRpt; reportsform.Show(); } catch (Exception ex) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)