OiO.lk Blog SQL How do I put in a combobox when the DISTINCT is used
SQL

How do I put in a combobox when the DISTINCT is used


I am trying to put in a combobox while using the DISTINCT is use.

It works without the DISTICNT

<

using (SqlConnection conn = new SqlConnection(zGV.csAviation))
{
    try
    {
        string query = "select '<Select>' as name, 0 as id union Select name, id from Airlines ORDER BY Name ";

        SqlDataAdapter da = new SqlDataAdapter(query, conn);
        conn.Open();
        DataSet ds = new DataSet();
        da.Fill(ds, "airline");
        cbxAirline.DisplayMember = "Name";
        cbxAirline.ValueMember = "ID";

        cbxAirline.DataSource = ds.Tables["airline"].DefaultView;
    }
    catch (Exception ex)
    {
        // write exception info to log or anything else
        MessageBox.Show("Error occured in Airline!");
    }
}



You need to sign in to view this answers

Exit mobile version