Creating a DSN record at runtime?

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

The key is stored in ODBC.INI, but when creating ODBC, it asks for the type of authentication (SQL or network input).

How can we set this option at runtime?

+3
source share
2 answers

These are simply registry values. Here's an article from MS on how to do this in VB6 that should be very easily updated to VB.Net (the main thing is that you need an article to see which registry settings you need): How to program the creation of DSN for SQL Server with using vb

.Net, RegistryKey.

+2

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
+1

Source: https://habr.com/ru/post/1758692/


All Articles