Skip to content
Advertisement

How make code for multiple search at the time in vb.net, SQL Server

For the last three months, I worked on code creating a single searching code in vb.net but I need help to make multiple search at the time like for ex:- I search in database using vb.net is done but then I need search shart + red olor is also done, then I need search shart + red color + brand + style and many more.

My main problem is I search multiple any, I need shart + red color + brand + style formal so how can i done. suggest me … check img for better understanding

search multiple at time

My single search code:

Advertisement

Answer

Here is an example of a query that allows you to search using zero, one or more parameters:

If a parameter is set to NULL then the @ColumnN IS NULL part is true and that set of criteria matches every record and is effectively ignored, otherwise the ColumnN = @ColumnN part will only match the appropriate records.

EDIT:

For the record, it has been pointed out when I’ve posted an example like this in the past that the database would use the same execution plan every time and thus may be somewhat inefficient for some queries. If that’s an issue for you, you should look at building the SQL dynamically on a case by case basis.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement