1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Dim Con, Rec, MsG, A
Set Con = CreateObject("ADODB.Connection")
Set Rec = CreateObject("ADODB.Recordset")
On Error Resume Next
Con.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=Myserver;DATABASE=base;UID=Myroot;PASSWORD=MyPass;"
If Err.Number <> 0 Then
MsG = "Erreur N°" & Err.Number & vbCrLf _
& "Description:" & vbCrLf & Err.Description & vbCrLf _
& "Impossible d'ouvrire la BD"
MsgBox MsG, vbCritical, "Erreur"
Else
A = "SELECT Cpntrole FROM Pdp"
Rec.Open A, Con
If Err.Number <> 0 Then
Con.Close
MsG = "Erreur N°" & Err.Number & vbCrLf _
& "Description:" & vbCrLf & Err.Description & vbCrLf _
& "Impossible d'ouvrire la table"
MsgBox MsG, vbCritical, "Erreur"
Else
If Rec.EOF Then
MsG = "Aucun enregistrement disponible pour cette requête"
MsgBox MsG, vbInformation, ""
Else
MsgBox Rec.Fields("Cpntrole")
End If
Con.Close
Rec.Close
End If
End If
Set Rec = Nothing
Set Con = Nothing |