Add a smart Search to an ASP application

Source: Internet
Author: User

Using ASP to achieve the function of the search engine is a very convenient thing, but, how to achieve a similar 3721 intelligent search? For example, when you enter the "Chinese people" in the search conditions box, automatically extracts "China", "people" and other keywords and search in the database. After reading this article, you will find that this function is so simple to achieve.

The first step is to create a database called Db_sample.mdb (this article takes the Access2000 database as an example) and creates a table t_sample in it. The table T_sample includes the following fields:

ID Auto Number

U_name text

U_info notes

The second step, we start to design the search page search.asp. The page includes a form (Frm_search) that includes a text box and a Submit button in the form. The form's Method property is set to "get" and the Action property is set to "Search.asp", which is submitted to the Web page itself. The code is as follows:

<!-- Search.asp -->
<form name="frm_Search" method="get" action="Search.asp">
请输入关键字:
<input type="text" name="key" size="10">
<input type="submit" value="搜索">
</form>

Below, you are entering a key part of implementing intelligent search.

First, establish a database connection. Add the following code at the beginning of the Search.asp:

<%
 Dim strProvider,CNN
 strProvider="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
 strProvider=strProvider & Server.MapPath("\") & "\data\db_Sample.mdb" 假设数据库存放在主页根目录下的data目录下
 Set CNN = Server.CreateObject("ADODB.connection")
 CNN.Open strProvider 打开数据库连接
%>

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.