I want to retrieve data by column from DataReader.
Now I'm using like this,
AdsCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT a,b,c,d FROM testTable";
AdsDataReader reader = cmd.ExecuteReader();
reader.Read();
string columnA = reader.GetValue(0).ToString(); // I want to use column name instead of index number
is there any way to get data by column name? like
string columnB = reader["B"].getValue();
Thank you!
Did you try this:
string columnA = Convert.ToString(reader["B"]);