Windows服务OLEDB连接 [英] Windows Service OLEDB-connection

查看:76
本文介绍了Windows服务OLEDB连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开一个连接到Excel文件的OLEDB连接时挂起的Windows服务,像这样:

-----------------------

using(var connection = new OleDbConnection(

" Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="  

+ fileName +" ;;扩展属性= \" Excel 8.0 \""))

{

connection.Open();

//开始使用连接

}

-----------------------

当作为控制台应用程序运行时,此代码工作正常。当我使用Visual Studio调试Windows服务时,我可以进入代码,直到我按下对connection.Open()的调用

解决方案

您好,


请下载
Microsoft Access数据库引擎2010可再发行组件
并安装它。


或者作为解决方法,你可以将业务逻辑解压缩到一个单独的控制台应用程序中,然后从Windows服务中调用该应用程序。这是一个类似的线程供您参考。


https://stackoverflow.com/questions/2028706/windows-service-hangs-when-opening- oledb-connection-to-excel-file


由于此问题与SharePoint无关,您可以将其发布到以下论坛,您将从那里获得更多帮助和确认答案。


https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=csharpgeneral


最诚挚的问候,


Dennis




I have a Windows Service that hangs when opening an OLEDB-connection to an Excel-file, like this:
-----------------------
using (var connection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" 
+ fileName + ";Extended Properties=\"Excel 8.0\""))
{
connection.Open();
// start using the connection
}
-----------------------
This code works fine when running as a console application. When I debug the Windows Service with Visual Studio, I can step into the code until I hit the call to connection.Open()

解决方案

Hi,

Please download Microsoft Access Database Engine 2010 Redistributable and install it.

Or as a workaround, you can extract the business logic into a separate Console Application, and just call that application from within Windows Service. Here is a similar thread for your reference.

https://stackoverflow.com/questions/2028706/windows-service-hangs-when-opening-oledb-connection-to-excel-file

As this question is not relate to SharePoint, you can post it to following Forum, you will get more help and confirmed answers from there.

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=csharpgeneral

Best Regards,

Dennis


这篇关于Windows服务OLEDB连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆