Using the methods of the SqlDataReader
, I can get the value of a column by passing in its name.
while (dr.Read())
{
size = dr["size"].ToString();
name = dr["name"].ToString();
}
In my case, the SQL script is created dynamically and column names can be typed in lower or upper cases. When I try to get value like
size = dr["size"].ToString();
it returns size
, but
size = dr["Size"].ToString();
throws an exception. How to get column value by column name case insensitive, is it possible without changing SQL script?