尝试在我的 D 驱动器 (D:\TaalTipsDocumenten) 上的文件夹中搜索索引文件时遇到异常 (OleDBException: Not specified Error)。我知道这段代码在过去(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 ErrorCode=-2147467259 HResult=-2147467259 消息=未指定错误 Source=System.Data StackTrace:在 System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr) 在 System.Data .OleDb.OleDbDataReader.GetRowHandles() 在 System.Data.OleDb.OleDbDataReader.ReadRowset() 在 System.Data.OleDb.OleDbDataReader.Read() 在 System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping 映射) 在 System.Data .Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) 在 System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 开始记录,Int32 maxRecords) 在 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 命令,CommandBehavior 行为)在 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) 在 TaalTips.Controllers.HomeController.Search(String word) 在 D:\Projects\TaalTips\TaalTips \Controllers\HomeController.cs:第 40 行,位于 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器,Object[] 参数) 的 lambda_method(Closure , ControllerBase , Object[] ) 在 System.Web.Mvc.ReflectedActionDescriptor.Execute( ControllerContext 控制器上下文,IDictionary字典
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 个参数)在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 的 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 的 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase
1.End() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker。 EndInvokeActionMethod(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() InnerException:
我已经尝试了一些东西:
- 重新启动 Windows 搜索服务
- 从文件夹中删除索引并重新添加
- 重启电脑
- 确保所有连接都已关闭
- 创建一个不同的文件夹并尝试那个(同样的错误)
- 使用 OleDbDataReader 和 reader.Next(),但给出相同的错误
有人有什么想法吗?
提前致谢 !