Question : mssql - I need to build multiple where conditions in a select statement using asp.net

iI need to know how to construct an mssql query where there is multiple conditions

                     <asp:TextBox ID="Year" runat="server" Text='<%# Bind("Year") %>'
                     <asp:TextBox ID="Model" runat="server" Text='<%# Bind("Year") %>'
                     <asp:TextBox ID="Make" runat="server" Text='<%# Bind("Year") %>'
                     <asp:TextBox ID="MilesHours" runat="server" Text='<%# Bind("MilesHours")
                     <asp:TextBox ID="Description" TextMode="MultiLine"  Width="300" rows="5"
                     <asp:TextBox ID="Location"  Width="300" runat="server" Text='<%# Bind
                     <asp:TextBox ID="Price" runat="server" Text='<%# Bind("Price") %
                                             

Answer : mssql - I need to build multiple where conditions in a select statement using asp.net

once you pass those parameters as variables to SQL then you can do something like this:

1:
2:
3:
4:
5:
select ... from yourtable
where 	(@year is null or [year] = @year) and
	(@Model is null or Model = @model) and
	(@make is null or make = @make) and
	.... and so on ....
Random Solutions  
 
programming4us programming4us