I am using the ODBCCP32.DLL extension to create a system DSN instead of letting user DIY.
the code is like this. the code below does not generate any error but it fail to create or delete(which i create later) the DSN. any help!
option explicit
Const ODBC_ADD_DSN = 1 ’ Add data source
Const ODBC_CONFIG_DSN = 2 ’ Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ’ Remove data source
Const ODBC_ADD_SYS_DSN = 4 ’ Add system data source
Dim dbDriver As String
Dim dbAttributes As String
Dim result As Integer
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 Click(Source As Button)
dbDriver = "SQL SERVER"
dbAttributes = "SERVER = EDOXSERVER,4310" & Chr$(0) _
& "DESCRIPTION = Faxcore DSN" & Chr$(0) _
& "DSN = faxcore" & Chr$(0) _
& "DATABASE = xms" & Chr$(0) _
& "UID = sa" & Chr$(0) _
& "PWD = dba" & Chr$(0)
Msgbox "START DSN"
result = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, dbDriver, dbAttributes)
Messagebox result
If result = False Then
Msgbox "There was an error establishing connection. ", 16, "Failure"
Else
Msgbox "Data source estalished."
End If
End Sub