0

I'm working on building a search model based on windows search in particular Dsearch sample in the following link http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7388 under Querying folder.

The problem is, I need to make this search method as a WCF service which I need to consume in asp.net application. As I've figured out the problem is in OleDbConnection object -which connects to the indexer provider with the windows application-.

it gives IErrorInfo.GetDescription failed with E_FAIL(0x80004005) exception upon calling

OleDbDataReader.read()

My question can OleDbConnection be used with WCF services?

Code:

    // 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();

Edit: I have exactly the same query in both console application and in WCF service

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"
4

0 に答える 0