是否可以使用 C# 创建持久 ODBC 连接?
我不想创建要在我的应用程序中使用的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否是最好的方法,但您可以简单地在保存文件数据源的目录中创建一个 .dsn 文件。 就我而言,它是 C:\Program Files\Common Files\ODBC\Data Sources。
这些文件只是文本文件,如下所示:
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:
听起来您希望通过您选择的 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.