943,865 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 1232
  • MS SQL RSS
Jan 12th, 2009
0

Allowing NULL search in SelectCommand of SQLDataSource

Expand Post »
Hi,

I am trying to do a search function on my GridView. However when I tried using ( LIKE '%' + @ea_name2 + '%' ), it would only return me values if "ea_name2" is not null. I would like that SQL statement to execute even when "ea_name2" is null. Any ideas?

MS SQL Syntax (Toggle Plain Text)
  1. SelectCommand="SELECT * FROM [ea] WHERE ([ea_name] LIKE '%' + @ea_name2 + '%') ORDER BY ea_name"

Thanks in advance!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dfs3000my is offline Offline
21 posts
since Dec 2008
Jan 12th, 2009
0

Re: Allowing NULL search in SelectCommand of SQLDataSource

Did you try SELECT * FROM [ea] WHERE ([ea_name] LIKE '%' + @ea_name2 + '%' or [ea_name] is null) ??
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: database copying from local to server
Next Thread in MS SQL Forum Timeline: Where is AlwaysUseDefaultCodePage?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC