Reputation: 10580
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
Upvotes: 2
Views: 2824
Reputation: 726809
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);
....
}
Upvotes: 4
Reputation: 223282
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 + "%");
Upvotes: 1