代码之家  ›  专栏  ›  技术社区  ›  KenD Abbas Hadavandi

ASP.NET OLEDB代码在IIS7上部署时中断

  •  5
  • KenD Abbas Hadavandi  · 技术社区  · 14 年前

    我正在尝试编写一个简单的网站(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服务器上都进行了测试)。

    1 回复  |  直到 14 年前
        1
  •  3
  •   Jaroslav Jandek    14 年前

    我猜你是在Vista或旧的操作系统上运行,而IIS是在2008服务器或更新的服务器上运行? 尝试 Provider=Search.CollatorDSO.1 (注意 .1

    编辑 :您应该使用其他用户帐户进行搜索(而不是asp.net应用程序运行时使用的默认“网络服务”)。有关更多信息,请参见注释。

    推荐文章