2

I have this query

 string query = "SELECT * from IMALSO3.V_BN_IVR_ACCT_BAL_MNO WHERE PHONENO Like '%':mobileNumber";

                    using (OracleCommand cmd = new OracleCommand(query, conn))
                    {
                        cmd.Parameters.Add("mobileNumber", phone8Digits);

but it seems that i am binding wrong,

what is the correct way plase?

thanks

2 Answers 2

5

You need to remove the single quote, and put the wildcard marker % into the value itself, not into the query string:

string query = "SELECT * from IMALSO3.V_BN_IVR_ACCT_BAL_MNO WHERE PHONENO Like :mobileNumber";

using (OracleCommand cmd = new OracleCommand(query, conn)) {
    cmd.Parameters.Add("mobileNumber", "%"+phone8Digits);
    ....
}
Sign up to request clarification or add additional context in comments.

Comments

1

Remove '%' from command text and pass it while adding parameter like:

string query = "SELECT * from IMALSO3.V_BN_IVR_ACCT_BAL_MNO WHERE PHONENO Like :mobileNumber";
using (OracleCommand cmd = new OracleCommand(query, conn))
{
   cmd.Parameters.Add("mobileNumber", "%" + phone8Digits);

If you want to compare phone8Digits like contains then use:

 cmd.Parameters.Add("mobileNumber", "%" + phone8Digits + "%");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.