我正在尝试编写一个简单的网站(ASP.NET v4),它将调用Windows搜索,查找特定的文件并将其返回给用户。我已经编写了以下示例:它在“remoteserver”上调用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开发环境中,这个功能运行良好,“result”包含文件路径。然而,如果我将其部署到运行在Server 2008上的本地IIS7服务器上,我会收到以下错误:
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服务器上测试过)。