These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: LIKE operator in SQL Query
PostPosted: Fri Aug 12, 2005 5:15 pm 
How do I get a LIKE operator to work in a SQl query? My qury looks like this:

string sql = @"SELECT {cust.*} FROM tblCustomer {cust} WHERE cust.strFirstName LIKE %:strFirstName%";
m_session.CreateSQLQuery(sql, "cust", typeof(Customer)).SetString("strFirstName", firstName).List();


and throws an exception:

Not all named parameters have been set: Iesi.Collections.ListSet []

if I modify the statement to:

string sql = @"SELECT {cust.*} FROM tblCustomer {cust} WHERE cust.strFirstName = :strFirstName";

it works fine. What should i do? Im running MS SQl2000 and the column is nvarchar(100)

Thanks
/Kalle


Top
  
 
 Post subject:
PostPosted: Sat Aug 13, 2005 4:24 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Looks like a bug to me, please create a JIRA issue.


Top
 Profile  
 
 Post subject: try setting the parameter value to "%"+val+"%
PostPosted: Tue Aug 16, 2005 11:12 am 
Newbie

Joined: Wed Aug 03, 2005 3:00 am
Posts: 3
try setting the parameter value to "%"+val+"%". It worked for us like this.

Thanks,
Dan

_________________
Dan Bunea
http://danbunea.blogspot.com


Top
 Profile  
 
 Post subject: Re: LIKE operator in SQL Query
PostPosted: Fri Oct 30, 2009 4:29 am 
Newbie

Joined: Fri Oct 30, 2009 4:25 am
Posts: 1
You can
"select * from abc where name like ('%:value' + '%')"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.