CSDN博客

img yiruoyun

索引服务调用代码(C#)

发表于2004/11/3 13:00:00  633人阅读

 

          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();

         }

阅读全文
0 0

相关文章推荐

img
取 消
img