Windows indexing search - OleDbException Not Specified Error

352 Views Asked by At

I'm getting an exception (OleDBException: Not specified Error) when trying to search in indexed files in a folder on my D-drive (D:\TaalTipsDocumenten). I know this piece of code worked in the past (2 months ago), but when trying to continue working on that project, it doesn't seem to work anymore.

During execution of the following code, I get an error on the following line:

adapter.Fill(dt);

I can say that the Datatable (dt) is filled correctly, but I still get an error on that line. Also when trying to use a OleDbDataReader with .Next() function, it runs over the results and throws me the error eventually.

var query11 = @"SELECT  System.DateCreated,
                                System.ItemName,
                                System.ItemUrl,
                                System.Size,
                                System.Search.HitCount FROM SystemIndex " +
                                @"WHERE scope ='file:D:/TaalTipsDocumenten' AND CONTAINS('" + word + "') ";

FileOverviewModel returnModel = new FileOverviewModel();
returnModel.Files = new List<FileModel>();
returnModel.Search = word;

DataTable dt = new DataTable();

using (OleDbConnection connection = new OleDbConnection(@"Provider=Search.CollatorDSO;Extended Properties=""Application=Windows"""))
using (OleDbCommand command = new OleDbCommand(query11, connection))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
    adapter.Fill(dt);
}

The error doesn't say much (Not specified):

System.Data.OleDb.OleDbException was unhandled by user code ErrorCode=-2147467259 HResult=-2147467259 Message=Not specified error Source=System.Data StackTrace: at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr) at System.Data.OleDb.OleDbDataReader.GetRowHandles() at System.Data.OleDb.OleDbDataReader.ReadRowset() at System.Data.OleDb.OleDbDataReader.Read() at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at TaalTips.Controllers.HomeController.Search(String word) in D:\Projects\TaalTips\TaalTips\Controllers\HomeController.cs:line 40 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() InnerException:

I tried some things already:

  • Restart Windows Search Service
  • Remove index from the folder and add it again
  • Restart computer
  • Make sure all connections are closed
  • Create a different folder and try on that one (same error)
  • Use OleDbDataReader and reader.Next(), but gives same error

Someone has any idea?

Thanks in advance !

1

There are 1 best solutions below

3
Karen Payne On

This is not a answer but instead a suggestion.

I would try eliminating the DataAdapter, see if you get the same exception via DataTable.Load as per Test1 or perhaps as in Test2 trying to cycle through the results.

Neither are meant to be a solution but rather a way to see if the exception is caused perhaps by reading specific data, perhaps from excessive rows etc.

Note, in Test2 I did one column. I would try that or all columns allow the loop to run and see if a specific row throws an exception then from there see if a specific column value is the issue.

using System;
using System.Data;
using System.Data.OleDb;

namespace Demo
{
    class Class1
    {
        void Test1()
        {
            var word = "Place a hard code value here";
            var query11 = @"SELECT  System.DateCreated,
                                System.ItemName,
                                System.ItemUrl,
                                System.Size,
                                System.Search.HitCount FROM SystemIndex " +
                                            @"WHERE scope ='file:D:/TaalTipsDocumenten' AND CONTAINS('" + word + "') ";


            DataTable dt = new DataTable();

            using (OleDbConnection connection = new OleDbConnection(@"Provider=Search.CollatorDSO;Extended Properties=""Application=Windows"""))
            {
                using (OleDbCommand command = new OleDbCommand(query11, connection))
                {
                    connection.Open();
                    try
                    {
                        dt.Load(command.ExecuteReader());
                        Console.WriteLine(dt.Rows.Count);
                    }
                    catch (Exception)
                    {
                        // place break-pointhere


                    }

                }
            }
        }
        void Test2()
        {
            var word = "Place a hard code value here";
            var query11 = @"SELECT  System.DateCreated,
                                System.ItemName,
                                System.ItemUrl,
                                System.Size,
                                System.Search.HitCount FROM SystemIndex " +
                                            @"WHERE scope ='file:D:/TaalTipsDocumenten' AND CONTAINS('" + word + "') ";


            using (OleDbConnection connection = new OleDbConnection(@"Provider=Search.CollatorDSO;Extended Properties=""Application=Windows"""))
            {
                using (OleDbCommand command = new OleDbCommand(query11, connection))
                {
                    connection.Open();
                    try
                    {
                        var reader = command.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Console.WriteLine($"Date: {reader.GetDateTime(0)}");
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // place break-pointhere


                    }

                }
            }
        }
    }
}