45fan.com - 路饭网

搜索: 您的位置主页 > 电脑频道 > 编程代码 > 阅读资讯:索引服务调用代码大全

索引服务调用代码大全

2016-08-31 10:11:37 来源:www.45fan.com 【

索引服务调用代码大全

private void Button1_Click(object sender, System.EventArgs e)

{

// Catalog Name

string strCatalog = "TestCatalog";

string strQuery="";

strQuery = "Select DocTitle,Filename,Size,PATH,URL from Scope() where FREETEXT('" +TextBox1.Text+ "')";

// TextBox1.Text is the word that you type in the text box to query by using Indexing Service.

string connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source="+strCatalog;

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connstring);

conn.Open();

System.Data.OleDb.OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);

System.Data.DataSet testDataSet = new System.Data.DataSet();

cmd.Fill(testDataSet, "SearchResults");

DataView source = new DataView(testDataSet.Tables[0]);

DataGrid1.DataSource = source;

DataGrid1.DataBind();

}

 

本文地址:http://www.45fan.com/bcdm/70240.html
Tags: 服务 索引 代码
编辑:路饭网
推广内容
推荐阅读
热门推荐
推荐文章
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部