ODBC 和 Windows 服务

发布于 2024-08-10 01:11:49 字数 261 浏览 3 评论 0原文

我是 Windows 服务的新手,而且...你猜对了,我有点卡住了。让我来描述一下——

我正在运行一个定时服务,该服务使用 OdbcDataReader 和 SqlBulkCopy 来 (1) 归档数据 (2) 规范 SQL 框上的数据。当我在 Windows 窗体项目中运行此代码时。效果很好。然后,当我将 DNS 的数据目录路径更改为本地驱动器而不是网络共享(只是在本地模拟环境)时,它也可以正常工作。

我显然错过了一些东西。任何帮助将不胜感激。

域名系统

I'm new to windows services and... you guessed it, I’m a bit stuck. Let me paint the picture –

I’m running a timed service that use an OdbcDataReader and SqlBulkCopy to (1) archive the data (2) normalize the data on a SQL box. When I run this code in a windows form proj. it works fine. Then, when I change the DNS’s Data Directory Path to a local drive, instead of the network share (just simulated the environment locally), it works as well.

I’m obviously missing something. Any help will be appreciated.

DNS

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬心 2024-08-17 01:11:49

当您运行 Windows 窗体项目时,它会使用您的登录帐户运行。
该服务使用 LocalSystem 帐户运行,该帐户可能无权访问 ODBC 设置中指定的网络共享。

您可以通过进入“服务属性”->“登录”选项卡来检查这一点,并使其使用您的帐户运行。如果有效,则可能是访问权限问题。

我建议创建一个仅具有足够访问权限来访问共享的用户帐户。

When you run the windows form project it runs using your login account.
The service runs using the LocalSystem account which probably does not have rights to access the network share specified in the ODBC settings.

You can check this by going into the Services Properties->Log On tab and make it run using your account. If it works then it probably was an access rights problem.

I would recommend creating a user account that just has enough access rights to access the share.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文