Hello,
Is there someone who can help ?
I'm trying to create an User DSN in Windows using VB code.
But the create always fales ! I followed the instructions
I got from Microsoft
General Declarations
---------------------
'Constant Declaration
Public Const ODBC_ADD_DSN = 1 ' Add data source
Public Const ODBC_CONFIG_DSN = 2 ' Configure (edit)
data source
Public Const ODBC_REMOVE_DSN = 3 ' Remove data source
Public Const vbAPINull As Long = 0 ' NULL Pointer --
Quote:
>0&
'Function Declare
#If Win32 Then
Public Declare Function SQLConfigDataSource
Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As
String) _
As Long
#Else
Public Declare Function SQLConfigDataSource
Lib "ODBCINST.DLL" _
(ByVal hwndParent As Integer, ByVal fRequest As
Integer, ByVal _
lpszDriver As String, ByVal lpszAttributes As String)
As Integer
#End If
Code behind command button
---------------------------
'DSN aanmaken
#If Win32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String
strDriver = "Microsoft Paradox Driver (*.db)"
strAttributes = strAttributes & "PARADOXNETHPATH =
C:\Windows\System32" & Chr$(0)
strAttributes = strAttributes & "DRIVERID = 538"
strAttributes = strAttributes & "DEFAULTDIR =
C:\DATA" & Chr$(0)
strAttributes = strAttributes & "DBQ = C:\DATA " &
Chr$(0)
intRet = SQLConfigDataSource
(vbAPINull,ODBC_ADD_DSN,strDriver, strAttributes)
If intRet Then
MsgBox "DSN Created", vbOKOnly
Else
MsgBox "Create Failed", vbCritical
Exit Sub
End If
Thanks in advance !
Bye