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(":AccountNo1", OracleType.VarChar, 200);
                accountnoParam.Value = "2320ACC";
                myCommand8.Parameters.Add(accountnoParam);
            }
            else
            {
                OracleParameter accountnoParam = new OracleParameter(":AccountNo1", OracleType.VarChar, 200);
                accountnoParam.Value = ddlAccountNo.SelectedValue;
                myCommand8.Parameters.Add(accountnoParam);
            }
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);
            }

Open in new window

dwezilAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tiagosalgadoCommented:
Try to create the paremeter outside your loop. And then set only your value on it.
myCommand3.Parameters.Add(":Description", OracleType.VarChar, 200);
Then on your If statement use
myCommand3.Parameters[":Description"].Value = your_value
0
dwezilAuthor Commented:
OracleParameter descripParam = new OracleParameter(":Description", OracleType.VarChar, 200);
           
            if (myReader.GetString(0) == "00000")
            {
               
                descripParam.Value = txtProjName.Text;
                myCommand3.Parameters.Add(descripParam);
            }
            else
            {
               
                descripParam.Value = myReader.GetString(2);
                myCommand3.Parameters.Add(descripParam);
            }

tried this, it skips the IF and added the ELSE value
0
tiagosalgadoCommented:
But have you already check the myReader.GetString(0) value?
Maybe you're getting a different value from DB as you expected.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

dwezilAuthor Commented:
yeah Ive checked, there is a value of 00000 in the table
0
dwezilAuthor Commented:
and its in the correct column that myreader is reading
0
tiagosalgadoCommented:
There's something strange in that. If statemente is not skipped if you realy getting the "00000" string. Try to re-check your value, make a breakpoint at your if statement and make a watch for your myReader.GetString(0) value.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.