I make a query to a database SQL attempt to bring the result to a radGridView .... I add the row but no data as it should?
private void radButton1_Click(object sender, EventArgs e)
{
if(txtNro.Text=="")
MessageBox.Show("DEBE INGRESAR UN NRO DE ORDEN", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
if (txtNro.Text != "")
{
conexion.Open();
SqlCommand consulta = new SqlCommand("select Convert(varchar(10),fecIni,103) as fecIni ,Convert(Varchar(10),fecFin,103) as fecFin from ordenes where nro_orden=@nro", conexion);
consulta.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNro.Text));
SqlDataReader registro = consulta.ExecuteReader();
if (registro.Read())
{
labelIni.Text = Convert.ToString(registro["fecIni"]);
labelFinal.Text = Convert.ToString(registro["fecFin"]);
}
else
{
MessageBox.Show("NO SE ENCONTRO EL NUMERO DE ORDEN INGRESADO", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
labelIni.Text = "";
labelFinal.Text = "";
}
conexion.Close();
DataTable dt = new DataTable();
conexion.Open();
SqlCommand consulta2 = new SqlCommand("select medicamento,cantidad,programa,precioUnit,precioFin from DetalleOrden where nro_orden=@nro",conexion);
consulta2.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNro.Text));
SqlDataAdapter da = new SqlDataAdapter(consulta2);
da.Fill(dt);
rgv.DataSource = dt;
conexion.Close();
}
}