Ken*_*enD 5 asp.net oledb windows-search
我正在尝试编写一个简单的网站(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();
Run Code Online (Sandbox Code Playgroud)
..这在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.
Run Code Online (Sandbox Code Playgroud)
我不知道下一步该去哪儿.我需要对IIS7或代码执行什么操作才能使其正常工作?同样,这在VS2010中运行良好(在Windows 7和Windows 2008 Server上都经过测试).
我猜您运行的是 Vista 或更旧的操作系统,而 IIS 运行在 2008 Server 或更新版本上?尝试Provider=Search.CollatorDSO.1(注意.1)。
编辑:您应该使用不同的用户帐户才能进行搜索(而不是运行 asp.net 应用程序的默认“网络服务”)。请参阅评论以获取更多信息。
| 归档时间: |
|
| 查看次数: |
4305 次 |
| 最近记录: |