1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Private Declare Function connexion Lib "MYODBC3.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal sDriver As String, ByVal sAttributes As String) As Long
Sub f()
'Appel de l'API pour la création du DSN,
'retour d'execution dans la variable iRet
'iRet <> 0 alors le DSN a été créé
'iRet = 0 alors la création a échoué
iRet = connexion(vbNull, 1, "DRIVER={MySQL ODBC 3.51 Driver}", "SERVER=localhost; DATABASE=test; UID=login; PWD=password; ")
If iRet Then
MsgBox "DSN Créé !", vbInformation
Else
MsgBox "La création du DSN a échoué !", vbCritical
End If
End Sub |
Partager