Hi,
I'm trying to setup DSN's dynamically using VB in Access. I've used the following source code (modified) from MSDN to try and connect to a Unify DBIntegrator Database.
Option Explicit
Const ODBC_ADD_SYS_DSN = 4 'Add data source
Const ODBC_CONFIG_SYS_DSN = 5 'Configure (edit) data source
Const ODBC_REMOVE_SYS_DSN = 6 'Remove data source
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
Function Build_SystemDSN(Description As String, ServerDSN As String, ServerName As String)
Dim ret%, Driver$, Attributes$
Driver = "Unify DBIntegrator Client" & Chr(0)
Attributes = "DSN=" & ServerDSN & Chr(0) & "DATABASE=" & ServerDSN & Chr(0) & "SERVER=" & "ServerName" & Chr(0)
Attributes = Attributes & "DESCRIPTION=" & Description & Chr(0) & "UID=" & Chr(0)
ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)
'ret is equal to 1 on success and 0 if there is an error
If ret <> 1 Then
MsgBox "DSN Creation Failed"
End If
End Function
I know the code works for other types of database, sql server and access for example, but when I try to run it for the Unify db it crashes out.
Any guesses on how I could find out what Attributes the database driver is expecting?
Many Thanks
Jim
I'm trying to setup DSN's dynamically using VB in Access. I've used the following source code (modified) from MSDN to try and connect to a Unify DBIntegrator Database.
Option Explicit
Const ODBC_ADD_SYS_DSN = 4 'Add data source
Const ODBC_CONFIG_SYS_DSN = 5 'Configure (edit) data source
Const ODBC_REMOVE_SYS_DSN = 6 'Remove data source
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
Function Build_SystemDSN(Description As String, ServerDSN As String, ServerName As String)
Dim ret%, Driver$, Attributes$
Driver = "Unify DBIntegrator Client" & Chr(0)
Attributes = "DSN=" & ServerDSN & Chr(0) & "DATABASE=" & ServerDSN & Chr(0) & "SERVER=" & "ServerName" & Chr(0)
Attributes = Attributes & "DESCRIPTION=" & Description & Chr(0) & "UID=" & Chr(0)
ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)
'ret is equal to 1 on success and 0 if there is an error
If ret <> 1 Then
MsgBox "DSN Creation Failed"
End If
End Function
I know the code works for other types of database, sql server and access for example, but when I try to run it for the Unify db it crashes out.
Any guesses on how I could find out what Attributes the database driver is expecting?
Many Thanks
Jim