我正在尝试编写一个简单的网站(ASP.NET V4),该网站将调用Windows搜索,查找特定文件并将其返回给用户。我将以下内容汇总为一个示例:它在“远程服务器”上调用Windows搜索服务,并返回“ somefile.txt”的路径:

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';";

OleDbCommand cmd = conn.CreateCommand();


cmd.CommandText = string.Format(
            "SELECT System.ItemPathDisplay, System.ItemType FROM " +
            " sytelhp.systemindex WHERE SCOPE='file://remoteserver/archive' AND CONTAINS(\"System.FileName\", " +
            " '\"*{0}*\"')", "somefile.txt");


conn.Open();

OleDbDataReader rdr = cmd.ExecuteReader();

string result=rdr[0].ToString();

..这在Visual Studio 2010开发环境中效果很好,“结果”包含了文件的路径。但是,如果我将其部署到本地IIS7服务器(在Server 2008上运行),则会获得此错误:

The parameter is incorrect. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: The parameter is incorrect.

我不知所措。我需要对IIS7或代码或两者都能做些什么才能使其正常工作?同样,这在VS2010(在Windows 7和Windows 2008服务器上测试)中正常工作。

有帮助吗?

解决方案

我猜您是在Vista或Elder OS上运行的,并且IIS在2008服务器上运行还是更新?尝试 Provider=Search.CollatorDSO.1 (注意 .1).

编辑: :您应该使用不同的用户帐户进行搜索(而不是默认的“网络服务”,ASP.NET应用程序运行在以下)。有关更多信息,请参见评论。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top