I have a combobox that I filled with this database query:
select ' ' as usr_entrada, null as no_servicio union select usr_entrada, No_Servicio from Telemarketing where Id_Sucursal='cordoba'
The idea of the union is to add a blank row to the selection, so that it appears in the combobox and can be selected. The fact is that the query correctly shows the results, in this way:
+--------------+-------------+
| usr_entrada | no_servicio |
+--------------+-------------+
| | NULL |
+--------------+-------------+
| CAPTURA-TMK | No_Servicio |
+--------------+-------------+
| SUP | No_Servicio |
+--------------+-------------+
| TCA02TMK | No_Servicio |
+--------------+-------------+
| TCACONTABAUX | No_Servicio |
+--------------+-------------+
| TMKCBA01 | No_Servicio |
+--------------+-------------+'
But when filling the combobox, the first line "disappears". The combobox filled it this way:
void llenaUsuarios()
{
Conexion con = new Conexion();
DataTable dt=new DataTable();
using (con.getcon())
{
const string sql = "select ' ' as usr_entrada, null as no_servicio union select usr_entrada, No_Servicio from Telemarketing where Id_Sucursal=@Sucursal";
using(SqlCommand cmd=new SqlCommand(sql, con.getcon()))
{
SqlDataReader rd;
cmd.Parameters.AddWithValue("@Sucursal", cveSucursal);
rd = cmd.ExecuteReader();
if (rd.HasRows)
{
rd.Read();
dt.Load(rd);
comboBox1.DisplayMember = "usr_entrada";
comboBox1.ValueMember = "no_servicio";
comboBox1.DataSource = dt;
}
}
}
}
Could someone explain to me why this happens? Tengro another combobox that is filled in the same way (although another query), and that does not erase anything.
I thank you in advance for your support.