I have 1 table with 2 columns ( Code and Value ). I'm writing a code in C # and I have a taxpercentage variable. What I need is to return the Code column value, when the variable taxpercentage is equal to the column Value . I have read the Value column and when I find match, I return the Code .
Forexample:Ifmyvariableis23.00,Iwanttoreturnthe6!I'vetriedthiscodebutitdoesnotwork:
conn.Open();SqlCommandcommand=newSqlCommand("SELECT Value, Code FROM IVA", conn);
SqlDataReader rd = command.ExecuteReader();
if(rd.HasRows)
{
while (rd.Read())
{
if (taxpercentage == rd["Value"].ToString())
{
codeiva = rd["Code"].ToString();
Console.WriteLine(codeiva);
}
}
}
conn.Close();
Does anyone know how I can do it?