dwezil
asked on
Trouble with If statement!
Hello, I have an if statement that changes a parameter's value depending on the value in a field that is selected earlier. The If statement should always run the if and the else because it is run in a loop and the value will be in one the the fields. I have replicated a previous IF that worked but for some reason it wont change the value of the parameter.
This is the working IF
if (myReader2.GetString(1) == "RV")
{
OracleParameter accountnoParam = new OracleParameter(":AccountN o1", OracleType.VarChar, 200);
accountnoParam.Value = "2320ACC";
myCommand8.Parameters.Add( accountnoP aram);
}
else
{
OracleParameter accountnoParam = new OracleParameter(":AccountN o1", OracleType.VarChar, 200);
accountnoParam.Value = ddlAccountNo.SelectedValue ;
myCommand8.Parameters.Add( accountnoP aram);
}
This is the working IF
if (myReader2.GetString(1) == "RV")
{
OracleParameter accountnoParam = new OracleParameter(":AccountN
accountnoParam.Value = "2320ACC";
myCommand8.Parameters.Add(
}
else
{
OracleParameter accountnoParam = new OracleParameter(":AccountN
accountnoParam.Value = ddlAccountNo.SelectedValue
myCommand8.Parameters.Add(
}
This is the IF I'm having problems with
if (myReader.GetString(0) == "00000")
{
OracleParameter descripParam = new OracleParameter(":Description", OracleType.VarChar, 200);
descripParam.Value = txtProjName.Text;
myCommand3.Parameters.Add(descripParam);
}
else
{
OracleParameter descripParam = new OracleParameter(":Description", OracleType.VarChar, 200);
descripParam.Value = myReader.GetString(2);
myCommand3.Parameters.Add(descripParam);
}
ASKER
OracleParameter descripParam = new OracleParameter(":Descript ion", OracleType.VarChar, 200);
if (myReader.GetString(0) == "00000")
{
descripParam.Value = txtProjName.Text;
myCommand3.Parameters.Add( descripPar am);
}
else
{
descripParam.Value = myReader.GetString(2);
myCommand3.Parameters.Add( descripPar am);
}
tried this, it skips the IF and added the ELSE value
if (myReader.GetString(0) == "00000")
{
descripParam.Value = txtProjName.Text;
myCommand3.Parameters.Add(
}
else
{
descripParam.Value = myReader.GetString(2);
myCommand3.Parameters.Add(
}
tried this, it skips the IF and added the ELSE value
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yeah Ive checked, there is a value of 00000 in the table
ASKER
and its in the correct column that myreader is reading
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
myCommand3.Parameters.Add(
Then on your If statement use
myCommand3.Parameters[":De