0
Hello, I am trying to make a code read what is in the SQL Server Database, but I have this error:
System.IndexOutOfRangeException: Pontos em System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) em System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) em System.Data.SqlClient.SqlDataReader.get_Item(String name)
Code:
public Usuario InitUsuario(SqlDataReader reader)
{
Usuario usuario = new Usuario();
usuario.pontos = (int)reader["Pontos"];
return usuario;
}
There is no column called
Pontos
what was returned by the query.– Oralista de Sistemas
But I created the Stitches column.
– Leonardo Araujo
@Leonardo Araujo, could post the columns of the database ?
– Dev
Maybe the column is "stitches"
– Dev
http://prntscr.com/gmmfha
– Leonardo Araujo
Have debug and see if you really have it, this screen doesn’t mean anything.
– Maniero
and select the query ?
– Rovann Linhalis
Like, I just created the table and placed the column, not by query.
– Leonardo Araujo
and where that came from
SqlDataReader
?– Rovann Linhalis
I don’t understand, Sqldatreader is by query?
– Leonardo Araujo
If I query the table, in the query it says that it exists
– Leonardo Araujo
Please send the complete code for the data reading.
– Bruno Jesus Santos