Your problem occurs because you are using your leer
object as if it were a method, but it is not, it is an instance of the class SqlDataReader
.
You can see it in the documentation of microsoft of the SqlDataReader class which are the methods and properties that it exposes, for this particular case, we are interested in:
Properties
Methods
Taking into account the aforementioned, we are going to your particular case
To apply the example, I'm going to assume that the column rut
is of type Int32
, and the rest chains.
SqlCommand cmd = new SqlCommand("Select rut,nombre,apellidop,apellidom from clientes where rut ='"+dato+"'");
SqlDataReader leer = cmd.ExecuteReader();
if (leer.Read())
{
//Obtengo el contenido de la primer columna de la query utilizando el método GetInt32(Int32)
int rut = leer.GetInt32(0);
//Obtengo el contenido de la segunda columna de la query utilizando el método GetString(Int32)
string resultado = leer.GetString(1);
//Obtengo el contenido de la tercer columna de la query utilizando la propiedad Item[String]
string nombre = leer["nombre"];
}
In case it was not clear, the parameter that is passed to the methods GetString(Int32)
and GetInt32(Int32)
is the position (starting from zero) of the column that is intended to be obtained within the query