I have a database that has four columns like this
level_1, level_2, level_3, level_4
There are also id, name, etc., but only these four are the ones that matter to me at the moment.
I need to know which column, by columnname, has the value 'BOSS'.
For example, level_2 may have the value BOSS. I need to know that one of the four columns has the code BOSS and which column, by column name, it is.
The reason is that I have to later update this row but I never know where the value BOSS will be. It could be in level_4, for example.
I know there is a columnname property in DataSet, but I cannot figure out how to use that here. I cannot post my code because there are many iterations of it, none of which work. I am hoping I am overlooking something obvious.
I am using ASP.NET 2.0 and ODBC.
Thank you for any ideas.
just to clarify - I do not need to know how to get the columnname per se. The columnname property works well for that. I do not know which column will have the value BOSS above. Once I can determine that I will get the columnname property value.
The reason I do not know which column will say BOSS is because there are other values that could be in any of the four so the data entry person has to pick an open field and put in the code - it is an old database application I inherited.
update:
Here is what i came up with. I do not like it but here it is. It works but it feels wrong:
String[] myValues = new String[5] {"BOSS", "ANOTHERCODE", "ANOTHERCODE", "ANOTHERCODE", "ANOTHERCODE"};
int x = 0;
foreach (String level in myValues)
{
foreach (DataColumn dc in ds.Tables[0].Columns)
{
String myColumnValue = ds.Tables[0].Rows[0][x].ToString();
if (myColumnValue == level)
{ return ds.Tables[0].Columns[x].ColumnName; }
x += 1;
}
x = 0;
}