Good afternoon.
I would like to know how I can show data in ComboBox
. This data I look for in SQL and I show them in a DataGridView
but I would like to show it in a ComboBox
, this is what I have of code.
public DataTable heater()
{
//conectar con la base de datos para extraer el hater segun el manufacturing order que le corresponda
SqlConnection con = new SqlConnection(consql);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = new SqlCommand("SELECT
spmh.[Samtec_Part_Master_Description]
FROM[production].[Pockets].[PocketHeater] as ph
inner join[production].[dbo].[SAMTEC_PART_MASTER] as spm
on ph.[PocketPartNumberId] = spm.[Samtec_Part_Master_ID]
inner join[production].[dbo].[SAMTEC_PART_MASTER] as spmh
on ph.[HeaterPartNumberId] = spmh.[Samtec_Part_Master_ID]
WHERE spm.[Samtec_Part_Master_Description] = '" + extraer() + "'
or spm.[Samtec_Part_Master_Description] = '" + prt + "' ", con);
da.Fill(ds);
dt = ds.Tables[0];
return dt;
}
and this is my formaplication.
private void txtbuscar_Click(object sender, EventArgs e)
{
clas.ordr = txtorder.Text;
clas.prt = txtpart.Text;
txtorder.Text = clas.limpio();
txtpart.Text = clas.extraer();
//txtheater.Text = clas.heater();
//lbheaters.Text = clas.heater();
//upheater.Text = clas.heater();
cbheater.DataSource = clas.heater();
dgvheater.DataSource = clas.heater();
}
And this is what is shown in ComboBox
.
Thank you.