Allowing NULL search in SelectCommand of SQLDataSource

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 19
Reputation: dfs3000my is an unknown quantity at this point 
Solved Threads: 0
dfs3000my dfs3000my is offline Offline
Newbie Poster

Allowing NULL search in SelectCommand of SQLDataSource

 
0
  #1
Jan 12th, 2009
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?

  1. SelectCommand="SELECT * FROM [ea] WHERE ([ea_name] LIKE '%' + @ea_name2 + '%') ORDER BY ea_name"

Thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Allowing NULL search in SelectCommand of SQLDataSource

 
0
  #2
Jan 12th, 2009
Did you try SELECT * FROM [ea] WHERE ([ea_name] LIKE '%' + @ea_name2 + '%' or [ea_name] is null) ??
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC