I just found this on the net and decided to pass it on. It is a free ocx that provides a simple method of creating and delete DSN connections. NO API's involved (but I suspect they are part of the ocx).
Download the ocx and the test project. Don't forget to manually register the ocx with regsr32.
My preliminary test were successful and the code was easy. Here is an example of the Vb code. 'DSN1' is the default name of the ocx.
Hope someone finds this useful.
Thanks and Good Luck!
zemp
Download the ocx and the test project. Don't forget to manually register the ocx with regsr32.
My preliminary test were successful and the code was easy. Here is an example of the Vb code. 'DSN1' is the default name of the ocx.
Code:
If Not DSN1.IsValid("TestDSN") Then ' if the DSN does not exist...
DSN1.DSN = "TestDSN" ' set the DSN name
DSN1.ServerName = "SERVER01" ' set the server name
DSN1.Database = "MyDatabase" ' set the database name
DSN1.UserName = "uid" ' your user id
DSN1.Password = "pwd" ' your password
DSN1.ODBCDriver = "SQL Server" 'this is the default value
DSN1.Description = "This is a description" ' set the description
DSN1.TrustedConnection = "Yes" ' make connection trusted
If DSN1.AddDSN Then ' if the add worked...
DSN1.DeleteDSN ' demonstrate delete
End If
End If
Hope someone finds this useful.
Thanks and Good Luck!
zemp