0

I am having trouble using parameters for my in line oraclae query in c#. Why does the parameter not work within the wildcard?

This line returns no results:

Select id, name from Users where UPPER(name) like '%:name%'
command.Parameters.Add("name", OracleDbType.Varchar2, name.ToUpper(), ParameterDirection.Input);

But this returns:

Select id, name from Users where UPPER(name) like '%" + name.ToUpper() +"%'
User456789
  • 397
  • 1
  • 3
  • 16
  • 1
    Possible duplicate of: http://stackoverflow.com/questions/19730941/how-to-use-wildcards-in-sql-query-with-parameters Check there, see if that answers your problem. – guildsbounty Mar 18 '15 at 14:38

1 Answers1

1

Did you mean this?

Select id, name 
from Users 
where UPPER(name) like '%' ||:name.ToUpper()||'%'

This concatenates your C# variable and the Oracle wildcard characters.

Prabhat G
  • 2,974
  • 1
  • 22
  • 31
kevinskio
  • 4,431
  • 1
  • 22
  • 36