открытие OleDbConnection через сервис WCF - PullRequest
0 голосов
/ 02 августа 2011

Я работаю над созданием модели поиска на основе поиска Windows, в частности, примера Dsearch по следующей ссылке http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7388 в папке запросов.

Проблема в том, что мне нужно выполнить этот поискметод как сервис WCF, который мне нужно использовать в приложении asp.net.Как я выяснил, проблема в объекте OleDbConnection, который подключается к провайдеру индексатора с приложением Windows.

это дает IErrorInfo.GetDescription с ошибкой E_FAIL (0x80004005) исключение привызов

OleDbDataReader.read()

Мой вопрос, можно ли использовать OleDbConnection со службами WCF?

Код:

    // Generate SQL from our parameters, converting the userQuery from AQS->WHERE clause
                string sqlQuery = queryHelper.GenerateSQLFromUserQuery(userQuery);

                // --- Perform the query ---
                // create an OleDbConnection object which connects to the indexer provider with the windows application
                System.Data.OleDb.OleDbConnection conn = new OleDbConnection(queryHelper.ConnectionString);

                // open it
                conn.Open();

                // now create an OleDB command object with the query we built above and the connection we just opened.
                OleDbCommand command = new OleDbCommand(sqlQuery, conn);

                // execute the command, which returns the results as an OleDbDataReader.
                 OleDbDataReader WDSResults = command.ExecuteReader();
          while (WDSResults.Read())
            {
                nResults++;
                // col 0 is always our path in display format
                string path = WDSResults.GetString(0);

                if (fScope)
                {
                    // if it is relative to the current directory, then just show the relative part of the path
                    path = path.Substring(Directory.GetCurrentDirectory().Length + 1);
                }

                if (fDisplayContents)
                {
                    // output the file to our WDSResult file to build the list of files for input to findstr
                    fileList.Add(path);
                }
                else
                {
                    List<string> val = new List<string>();
                    // if they have a custom sort column
                    if ((fBare == false) && (sortCol != "System.ItemPathDisplay"))
                    {
                        // then get it 
                        val[0] = WDSResults.GetValue(1).ToString();

                        // and output it
                        return val[0];
                    }
                    return val[0] + path;
                    // output the path
                    //Console.WriteLine(path);
                }
            }
            WDSResults.Close();
            conn.Close();

Редактировать: У меня точно такой жезапрос как в консольном приложении, так и в службе WCF

CommandText = "SELECT \"System.ItemPathDisplay\" FROM \"SystemIndex\" WHERE CONTAINS(*,'\"soa*\"',1033) AND scope='file:D:\\4Project' ORDER BY System.ItemPathDisplay ASC"

CommandText = "SELECT \"System.ItemPathDisplay\" FROM \"SystemIndex\" WHERE CONTAINS(*,'\"soa*\"',1033) AND scope='file:D:\\4Project' ORDER BY System.ItemPathDisplay ASC"
...