1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'chemin d'accès a ta base Access
dim path = "C:\Ton\Chemin"
'teste ta connexion
Try
'défini ta connexion
TonDGVTableAdapter.Connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Persist Security Info=False"
'ouvre et ferme la connexion (ne pas oublier de la fermer !)
Me.TonDGVTableAdapter.Connection.Open()
Me.TonDGVITableAdapter.Connection.Close()
'gère ton exception
Catch ex As Exception
MsgBox("Impossible de se connecter aux données.", vbCritical + vbOKOnly, "Connexion aux bases de données")
End Try |
Partager