Luv L

Luv L

  • 1.3k
  • 141
  • 7.2k

how to load sum of value while select from combo box item c# WinForms

May 2 2023 1:49 PM
private void mComBale_SelectedIndexChanged(object sender, EventArgs e)
{
    try
    {
       
        string query1 = "SELECT baleno, SUM(mtrs) FROM tbChallan GROUP BY baleno'" + mComBale.SelectedItem.ToString() + "'";
        cm = new SqlCommand(query1, con);
        con.Open();
        dr = cm.ExecuteReader();
        while (dr.Read())
        {
            rsLblBaleTotal.Text = dr["baleno"].ToString();
        }
        dr.Close();
        con.Close();
    }
    catch(Exception ex)
    {
       MessageBox.Show(ex.Message);
    }
}

syntax is I write correctly. but when I select the item from combobox then I need sum of mtrs from baleno

any correction in code??

pls help


Answers (2)