Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with cicle, one result, but it does not goes trought it
    text
    copied!<p>I have a cicle for validation, but for some reason it does not go trought the cicle </p> <p>Look at the comments, the while cicle it seems does nothing</p> <p>If ther is any method to retrieve one result plase tell me how to do it</p> <p>Here is my code, any help would be appreciated</p> <pre><code>private bool validar_ultimo_movimiento(Int64 cedula) { bool validar = false; DateTime tipo = Convert.ToDateTime("00:00:00"); SqlConnection Wdcon_usuario = new SqlConnection(WDcon); SqlCommand usuario = new SqlCommand(); SqlDataReader usuarioDR = null; //Instancio la conexion SQL usuario.Connection = Wdcon_usuario; //Registro el Query SQL usuario.CommandText = "SELECT TOP 1 * FROM movimiento_docente WHERE (ID = @cedula) ORDER BY id_movimiento DESC"; usuario.Parameters.AddWithValue("@cedula", cedula); //Abro la conexion Wdcon_usuario.Open(); //Ejecuto la consulta usuarioDR = usuario.ExecuteReader(); //Empiezo el ciclo while (usuarioDR.Read()) { MessageBox.Show("Paso por aca 2"); // &lt;- It does not execute if (usuarioDR["fechahora"].ToString() != "") { MessageBox.Show("Paso por aca 3"); tipo = (DateTime)usuarioDR["fechahora"]; MessageBox.Show(tipo.ToString()); } else { validar = true; MessageBox.Show("Paso por aca 1"); } } //Cierro la conexion Wdcon_usuario.Close(); //Termino la sentencia SQL DateTime valoringresado = Convert.ToDateTime(dtHoraManual.Value); MessageBox.Show("Valor Ingresado = " + valoringresado.ToString() + " Valor BD = " + tipo.ToString()); if (valoringresado &gt; tipo) { validar = true; } else { validar = false; } return validar; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload