Windows 索引搜索 - 未指定 OleDbException 错误



尝试在我的D驱动器(D:\TaalTipsDocumenten(上的文件夹中搜索索引文件时,我遇到了异常(OleDBException:未指定错误(。我知道这段代码在过去(2 个月前(有效,但是当尝试继续处理该项目时,它似乎不再有效。

在执行以下代码期间,我在以下行收到错误:

adapter.Fill(dt);

我可以说数据表(dt(正确填充,但我仍然在该行上遇到错误。同样在尝试将 OleDbDataReader 与 .Next(( 函数,它会运行结果并最终向我抛出错误。

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);
}

该错误没有说明太多(未指定(:

System.Data.OleDb.OleDbException 未由用户代码处理 错误代码=-2147467259 HResult=-2147467259 消息=未指定错误 源=系统.数据 堆栈跟踪: 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(闭包、控制器库、对象[] ( 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 参数( 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( 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d(( at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f(( 内部异常:

我已经尝试了一些事情:

  • 重新启动 Windows 搜索服务
  • 从文件夹中删除索引,然后再次添加
  • 重新启动计算机
  • 确保所有连接均已关闭
  • 创建一个不同的文件夹并尝试该文件夹(相同的错误(
  • 使用 OleDbDataReader 和 Reader。Next((,但给出相同的错误

有人知道吗?

提前感谢!

这不是一个答案,而是一个建议

我会尝试消除DataAdapter,看看您是否通过DataTable.Load根据Test1或测试2尝试循环结果时遇到相同的异常。

两者都不是解决方案,而是一种查看异常是否可能是由读取特定数据引起的方法,也许是从过多的行等。

请注意,在 Test2 中,我做了一列。我会尝试或所有列都允许循环运行,并查看特定行是否引发异常,然后从那里查看特定列值是否是问题所在。

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

}
}
}
}
}
}

相关内容

最新更新