I am using c# .NET.
I have 3 fields(Text Boxes) txtName,txtSirname, txtLocation.
My database table is
Name | Sirname | Location
Steve | Jobs | US
Kevin | Peterson | UK
Haechelle | Gibbs | South Africa
I have one search button. On the click of search button i want to display all the results according to text boxex.
BUT
If all the text boxes are empty i want to display whole table.
If name is empty then it should disply result according to sirname and place.
If sirname is empty then it should display result according to name and place.
If name and sirname is empty… and all the possible combinations.
My problem is that i am not allowed to use if statement in C#. I have to write it in one SQL query only. How should i do it. please direct me.
Use
If your textboxes are empty pass
NULLas the value of parameters in your query / sproc.