在运行时创建 DSN 条目?

发布于 2024-09-13 15:44:04 字数 130 浏览 1 评论 0原文

如何在运行时从 VB.NET 以编程方式添加系统 DSN 及其安全凭证?

将密钥保存在 ODBC.INI 中已完成,但在创建 ODBC 时,它会要求身份验证类型(SQL 或网络登录)。

我们如何在运行时设置该选项?

How can you add a system DSN with its security credentials programmatically at runtime from VB.NET?

Keeping key in ODBC.INI is done, but when creating ODBC, it asks for Authentication Type (SQL or Network Login).

How can we set that option at runtime?

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

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

发布评论

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

评论(2

剑心龙吟 2024-09-20 15:44:04

这只是注册表值。这是 MS 的一篇关于如何在 VB6 中执行此操作的文章,应该很容易升级到 VB.Net(您需要这篇文章的主要目的是查看您需要哪些注册表设置等): 如何使用 VB 以编程方式为 SQL Server 创建 DSN

如果您以前没有使用过 .Net 注册表,我'建议您从 RegistryKey 类开始。

It's just registry values. Here's an article from MS about how to do it in VB6, should be very easy to upgrade to VB.Net (the main thing you need the article for will be to see what registry settings etc you need): How To Programmatically Create a DSN for SQL Server with VB

If you haven't used the registry for .Net before, I'd suggest that you start with the RegistryKey class.

倾城泪 2024-09-20 15:44:04

在 VB.NET 中(假设这是一台 32 位计算机),您希望将该键设置为“HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI”。
如果您的 ODBC 密钥不存在,请在此处创建它,并在您的密钥下填充以下字符串值:

Database - Your DB Name here<br />
Driver - Default SQL Server driver path would be "C:\WINDOWS\System32\SQLSRV32.dll"<br />
Server - Your SQL Instance Name Here<br />
Trusted_Connection - Yes or No

In VB.NET (assuming this is a 32 bit machine) you want to set that keys at "HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI".
Under there create your ODBC Key if it does not exist and populate the following string values under your key:

Database - Your DB Name here<br />
Driver - Default SQL Server driver path would be "C:\WINDOWS\System32\SQLSRV32.dll"<br />
Server - Your SQL Instance Name Here<br />
Trusted_Connection - Yes or No
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文