1.表结构:
字段名称 字段类型 字段含义
id Varchar(11) 编号
title Varchar(50) 标题
content Text 内容
2.程序流程
1) 打开数据库;
2) 建立索引;
3) 根据索引进行全文搜索.
4.附源码:
aspx文件:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication4.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>使用Lucene.net建立简单的数据库搜索程序</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form ,new ChineseAnalyzer());
hits=mysea.Search(query);
}
catch(Exception e)
{
Response.Write(e);
}
return hits;
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Search.Click += new System.EventHandler(this.Search_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Search_Click(object sender, System.EventArgs e)