We help IT Professionals succeed at work.

Programmatically creating a System DSN

d_glenn
d_glenn asked
on
How do I programmatically create a System DSN (ODBC)?  I need to roll out an application to a large amount of users that requires a System DSN to function properly.  I would like to automate the process of creating the DSN so that users just need to run a small .exe or script that automates the process.

Thanks
DG
Comment
Watch Question

Commented:
You have to add to this registry key,

HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\ODBC Data Sources

Add a String Value to the Key, in the Value Data add the Driver Name.

Need More?,
RH.


Senior DBA
CERTIFIED EXPERT
Commented:
Here's an Microsoft Knowledgebase article on how to do that:

http://support.microsoft.com/support/kb/articles/Q171/1/46.asp

Here's a code project showing in detail how to create system DSNs:

http://www.planet-source-code.com/xq/ASP/txtCodeId.23357/lngWId.1/qx/vb/scripts/ShowCode.htm

Commented:
You have to add to this registry key,

HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\ODBC Data Sources

Add a String Value to the Key, in the Value Data add the Driver Name.

Need More?,
RH.


Author

Commented:
I prefer using an API call as shown in the MS URL, but this creates a "User" DSN rather an a "System" DSN.

Any ideas as to how this example could be changed to do a system dsn?

Author

Commented:
The MS example is exactly what I couldn't find.  Thanks.  Just had to change the ODBC_ADD_DSN constant from 1 to 4 to create a "system" instead of "user" DSN.

Thanks to all.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.