cs_smartghost
Messages postés60Date d'inscriptionvendredi 13 avril 2007StatutMembreDernière intervention 7 mars 2008
-
26 mai 2007 à 14:08
andalo
Messages postés103Date d'inscriptionlundi 23 avril 2007StatutMembreDernière intervention20 octobre 2012
-
6 mai 2008 à 08:57
Bonjour,
S-V-P je souhaitrai savoire comment acceder avec VB6 a une base de donnees sous access 2007
Merci d'avance !
cs_ghuysmans99
Messages postés3983Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 26 mai 2007 à 15:00
encore !
tout d'abord, nous allons utiliser ADODB
tu dois donc ajouter "Microsoft Active Data Objects 2.x Library" x êtant le plus grand (normallement 8)
dans un module que tu nommes Database tu mes :
Option Explicit
Public Conn As New ADODB.Connection
Public Conn_ConnStr As String
Public Sub OpenConn(DBPath As String)
Set Conn = New ADODB.Connection
Conn_ConnStr = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & DBPath & ";Uid=Admin;Pwd=Admin;PassWord=Admin;"
Conn.ConnectionString = Conn_ConnStr
Conn.Open
End Sub
Public Sub CloseConn()
On Error Resume Next
Conn.Close
On Error GoTo 0
Set Conn = Nothing
End Sub
cs_ghuysmans99
Messages postés3983Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 26 mai 2007 à 18:03
OOOps ...
Option Explicit
Public Conn As New ADODB.Connection
Public Conn_ConnStr As String
Public Sub OpenConn(DBPath As String)
Set Conn = New ADODB.Connection
Conn_ConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:\Database1.accdb;Persist Security Info=False;"
Conn.ConnectionString = Conn_ConnStr
Conn.Open
End Sub
Public Sub CloseConn()
On Error Resume Next
Conn.Close
On Error GoTo 0
Set Conn = Nothing
End Sub
andalo
Messages postés103Date d'inscriptionlundi 23 avril 2007StatutMembreDernière intervention20 octobre 2012 5 mai 2008 à 17:42
Bonjour,
je n'ai pas encore testé le code mais ton dernier post me perturbe ghuysmans99. Pourquoi faut il mettre
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DbPath & ";Persist Security Info=False;"???
Il doit y avoir une subtilité que je ne saisie pas, d'une facon naturelle, j'aurai mis
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= DbPath;Persist Security Info=False;"
cs_ghuysmans99
Messages postés3983Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 5 mai 2008 à 19:07
Et ben non ... DBPath êtant la variable contenant le chemin de la base.
_______________________________________________________________________
VB.NETis good ...VB6is better