Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/05/2009, 16:58
LOD_Fredy
 
Fecha de Ingreso: abril-2009
Mensajes: 341
Antigüedad: 15 años, 10 meses
Puntos: 3
Respuesta: realizar una busqueda desde c#

Para ese mismo boton intente usar el elemento SqlDataReader de una forma muy parecida al DataTable pero tampoco funciono, dejo el codigo del metodo consultar donde uso el DataReader:

Código:
public SqlDataReader Consultar(int userID)
        {
            SqlDataReader Lector = null;
            if (Conectar(Properties.Settings.Default.strUser, Properties.Settings.Default.strPass))
            {                
                SqlCommand comando = new SqlCommand();
                try
                {
                    conexion.Open();
                    comando.CommandText = "SELECT * FROM USUARIO WHERE userID  = @userID";
                    comando.Parameters.Clear();
                    SqlParameter param_userID = new SqlParameter("@userID", SqlDbType.Int);
                    param_userID.Value = userID;

                    comando.Parameters.Add(param_userID);
                    Lector = comando.ExecuteReader();
                    //Lector.Read();                                        
                }
                catch
                {
                }
                finally
                {
                    if (Lector != null)
                        Lector.Close();
                    conexion.Close();
                }
                return Lector;
            }
            return Lector;
        }