我正在尝试编写一个简单的网站(ASP.netv4),它将调用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();
.. 这在visualstudio2010开发环境中非常有效,“result”包含文件的路径。但是,如果将其部署到本地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中工作良好(在windows7和windows2008服务器上都进行了测试)。