首页 > 开发 > 综合 > 正文

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

2024-07-21 02:18:34
字体:
来源:转载
供稿:网友


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

}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表