是否可以使用 C# 创建持久 ODBC 连接?

发布于 2024-07-17 01:27:59 字数 150 浏览 2 评论 0原文

我不想创建要在我的应用程序中使用的 ODBC 连接。 我正在使用另一种脚本语言(我别无选择),该语言使用 odbcad32(Microsoft ODBC 源管理器)中定义的本地 ODBC 连接。 我想以编程方式更改 odbcad32 中的服务器,然后使用新信息调用脚本来执行其操作。

I'm not trying to create an ODBC connection to be used in my application. I am working with another scripting language (I have no choice) that uses a local ODBC connection defined in odbcad32 (the Microsoft ODBC Source Administrator). I want to programmatically change the server in in odbcad32, and then call the script to do what it does, using the new information.

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

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

发布评论

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

评论(2

偏爱你一生 2024-07-24 01:27:59

我不确定这是否是最好的方法,但您可以简单地在保存文件数据源的目录中创建一个 .dsn 文件。 就我而言,它是 C:\Program Files\Common Files\ODBC\Data Sources。

这些文件只是文本文件,如下所示:

[ODBC]
DRIVER=SQL Server
UID=myName
Trusted_Connection=Yes
DATABASE=Test
WSID=ServerName
APP=Microsoft Data Access Components
SERVER=(local)

I'm not sure if this is the best way, but you can simply create a .dsn file in the directory where your File Data Sources are kept. In my case that is C:\Program Files\Common Files\ODBC\Data Sources.

The files are just text files that look something like this:

[ODBC]
DRIVER=SQL Server
UID=myName
Trusted_Connection=Yes
DATABASE=Test
WSID=ServerName
APP=Microsoft Data Access Components
SERVER=(local)
浅紫色的梦幻 2024-07-24 01:27:59

听起来您希望通过您选择的 DBMS 从您选择的语言获得一个工作队列,并最终运行 C# 代码。 如果您在 Windows 或其他支持消息队列系统的地方使用某种语言(未指定),那么这可能是您最好的选择。 简短的回答是,是的,您可以保持持久连接。 使用 MS-SQL 2005+,您甚至可以创建用 C# 编写的嵌入式代码来响应事件和函数。

如果您想要更具体的答案,提出更具体的问题会有所帮助。

Sounds like you want a work queue from your language of choice via your DBMS of choice, and have C# code run as a result. If you are using a language (didn't specify) on windows, or elsewhere that supports a Message Queue system, this may be your best bet. The short answer is, yes you can maintain a persistent connection. With MS-SQL 2005+ you can even create embedded code that is written in C# to respond to events, and functions.

If you would like a more specific answer, it would help to ask a more specific question.

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