Implement a search function in the database, database search function

Source: Internet
Author: User
Tags sql 2008

Implement a search function in the database, database search function

During application development, Insus. NET has used many different methods to implement the search function for ASP. NET.

Writing SQL statements in a program or writing a category can be shared by multiple programs, and conditional expressions can be directly transmitted to the database for processing.
Insus Search Utility Ver2 http://www.cnblogs.com/insus/p/3223940.html

How to Implement search function on Web site http://www.cnblogs.com/insus/archive/2011/03/30/1999795.html

Implementation of a search function ideas http://www.cnblogs.com/insus/archive/2013/04/06/3002054.html

Search and dynamic display field http://www.cnblogs.com/insus/archive/2010/06/17/1759672.html

SQL stored procedure passed in with expressions as parameters go to http://www.cnblogs.com/insus/articles/1360985.html

 

No matter what the above form is, it is finally passed into the database using an SQL expression. In this case, Insus. NET wants to use another scenario. The database uses SQL 2008 or later.
First, define a type [dbo]. [udt_SearchCondition] in the database:

It can also be said that this was previously written as a class in the program, but now it is written in SQL.
When you use this function, you do not have to write too much (CODE ). For example, if the text boxes below are used as search conditions, how can we transfer the value to the database and use the User-Defined table [dbo]. udt_SearchCondition] type previously written:


The three conditions in front of the above are the drop-down list. Of course, there is no problem with Textbox in the file box. First, let's make a judgment. If it is not empty, write a record and insert it into the DataTable, at last, the DataTable is passed into the database. Or two date text boxes. If the user only fills in the first box, it is to query records greater than or equal to the write date. If only the last text box is filled in, it indicates that the user queries records that are less than or equal to this date. If both the text boxes are filled in, the user queries the records between this date.

The above shows a method objSixS. GetCustomizatorStatisticReport ():


 

There is a BizSP sp = new BizSP:
Can refer to this: Program and Database Connection Bridge and logic processing http://www.cnblogs.com/insus/p/4156735.html

Also in a stored procedure usp_SixS_SearchForStatistics:


In the above stored procedure, there is another [dbo]. [udf_SearchConditionStatement] (), whichThe User-Defined Functions function converts the type [dbo]. [udt_SearchCondition] to an SQL WHERE condition:



OK. It is easy to do some simple search.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.