我正在尝试编写一个简单的网站(ASP.NET v4),它将调用 Windows 搜索,查找特定文件并将其返回给用户。我将以下内容作为示例:它调用“remoteserver”上的 Windows Search 服务,并返回“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 Server 上进行了测试)。
我猜您运行的是 Vista 或更旧的操作系统,而 IIS 运行在 2008 Server 或更新版本上?
尝试Provider=Search.CollatorDSO.1
(注意.1).
Edit:您应该使用不同的用户帐户才能进行搜索(而不是运行 asp.net 应用程序的默认“网络服务”帐户)。请参阅评论以获取更多信息。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)