2

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 !

Dennis
  • 164
  • 1
  • 9

1 Answers1

0

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


                    }

                }
            }
        }
    }
}
Karen Payne
  • 4,341
  • 2
  • 14
  • 31
  • Thanks for the suggestions. I already tried your test 2 with the use of a reader and I get the same error in the line reader.Read(). I said this in my post as last point that I tried: - Use OleDbDataReader and reader.Next(), but gives same error Going to try your first test now ! – Dennis Jul 25 '17 at 13:21
  • Thinking Test2, do you know how many reads execute before the error is thrown on reader.Next() ? Have you tried removing the contains part of the WHERE clause? Have you tried removing some fields in the SELECT e.g. I might start by removing ItemUrl for instance and try again. – Karen Payne Jul 25 '17 at 13:30
  • I tried your Test1 option too and still get the same problem. I also tried removing everything and just select 1 field from SystemIndex (even without WHERE clause), but I keep on getting the same error... All the needed records that need to be found are stored in the datatable actually (in my test case only 6), but in the end he probably throws this error? No idea why. So there's nothing wrong with the data it seems. – Dennis Jul 25 '17 at 13:36