Normally in order to create an ODBC data source name (DSN) you have to, in NT4 anyway, do it via Start->Settings->ControlPanel->Data Sources(ODBC). Once here you click on the ADD button and fill in the values on-screen as required. However this is no use if you are sending a program to clients and want the DSN to be set up automatically. I had just this problem recently. I need to have a text Driver DSN set up on my clients machine but didn't want them to have to do it as this is potentially a very error prone task. The good news is that it can be done programmatically. In the example below a text driver USER DSN is going to be set up but the example can be tweaked to set up any other kind of DSN you might require. Here's the code.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndparent As Long, ByVal frequest As Long, _
ByVal lpszdriver As String, ByVal lpszattributes As String) _
As Long
Sub Main()
Dim intret As Long
Dim atts As String
Dim strdriver As String
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.