-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule1.bas
More file actions
22 lines (16 loc) · 722 Bytes
/
Module1.bas
File metadata and controls
22 lines (16 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Attribute VB_Name = "Module1"
Sub GC()
Dim conn As Object ' Déclarez la variable pour l'objet Connexion
On Error GoTo Erreur ' Activez la gestion des erreurs
' Initialisez l'objet Connexion
Set conn = CreateObject("ADODB.Connection")
' Essayez d'établir une connexion
conn.Open "Driver={MySQL ODBC 9.1 Unicode Driver};Server=localhost;Database=BD_Gestion_de_Commandes;User=root;Password=adam123;"
' Si la connexion réussit
MsgBox "Connexion réussie !"
Erreur:
' Capturez et affichez les erreurs
MsgBox "Erreur : " & Err.Description, vbCritical
If Not conn Is Nothing Then conn.Close ' Fermez la connexion si elle est ouverte
Set conn = Nothing
End Sub