Connexion vb6 et Access

samahabab7 Messages postés 9 Date d'inscription samedi 7 avril 2012 Statut Membre Dernière intervention 8 mai 2014 - 11 mai 2012 à 19:07
samahabab7 Messages postés 9 Date d'inscription samedi 7 avril 2012 Statut Membre Dernière intervention 8 mai 2014 - 18 mai 2012 à 23:13
Salut a tous!

je suis nouvelle dans ce site .
je suis Etudiante, je développe une application de connexion entre Access et Visual basic 6 mais je trouve un problème dans le code (ajout,modification ) si on clique sur le bouton modifier par exemple (dans l'interface vb) la page de base de données Access s'affiche et je peux modifier les données mais dans ma code le bouton modifier ne fonctionne pas ; avec connaissance que la connexion a Access sa marche bien
Aidez moi SVP et marci d'avance

3 réponses

Tupad Messages postés 239 Date d'inscription lundi 5 décembre 2005 Statut Membre Dernière intervention 27 août 2012 5
16 mai 2012 à 16:02
Tu peux ajouter le code qui plante avec l'erreur retournée s'il y en a une?
0
samahabab7 Messages postés 9 Date d'inscription samedi 7 avril 2012 Statut Membre Dernière intervention 8 mai 2014
18 mai 2012 à 22:54
salut! Tupad

voila mon code ;il est plein d'erreurs
[C:/ss/pharmacie.zip code]
merci d'avance
0
samahabab7 Messages postés 9 Date d'inscription samedi 7 avril 2012 Statut Membre Dernière intervention 8 mai 2014
18 mai 2012 à 23:13
salut Tupad

voila mon code
Class connexion:

Option Explicit
Private v_con As New ADODB.Connection
Private v_com As New ADODB.Command
Private v_res As New ADODB.recordset
Public Sub connect()
Dim con As ADODB.Connection
Set con = New ADODB.Connection

v_con.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/pharmacie2012/data/pharmacien1.mdb"

v_con.open


v_res.CursorLocation = adUseClient

v_res.LockType = adLockOptimistic
v_res.ActiveConnection = v_con

End Sub
Public Sub selection(ByVal req As String)
v_res.Source = req
v_res.open = req1
End Sub
Public Sub modification(ByVal req As String)
v_com.ActiveConnection = v_con
v_com.CommandText = req
v_com.Execute
End Sub
Public Property Get recordset() As recordset
Set recordset = v_res
End Property
Public Property Let recordset(ByRef res As recordset)
Set v_res = res
End Property

form2(frmMedicament.frm):
Dim con As New ClassConnexion
Dim m As String
Dim ref_inter() As Variant
Dim i, compt As Integer


Private Sub ajouter_click()
v_con.open
i = v_res.Fields.Count
For compt = 0 To i - 1
v_res.Fields(ref_inter(compt)) = Form2(ref_inter(compt)).Text
Next compt
v_res.Update
v_res.Close
dataEnvironement1.Command1.Add
End Sub

Private Sub Command4_Click()
Unload Me
Load Form1
Form1.Show
End Sub

Private Sub DataGrid1_Click()

text1 = DataGrid1.Columns(0).Value
Text2 = DataGrid1.Columns(1).Value
text3 = DataGrid1.Columns(2).Value
text4 = DataGrid1.Columns(3).Value
text5 = DataGrid1.Columns(4).Value
text6 = DataGrid1.Columns(5).Value
text7 = DataGrid1.Columns(6).Value
text8 = DataGrid1.Columns(7).Value

End Sub





Private Sub Command2_Click()

msg = MsgBox("etes vous sur de vouloir suprime", vbYesNo, "confirmation")
If msg = vbYes Then

dataEnvironement1.Command2.Delete
End If

End Sub


Private Sub MSFlexGrid1_Click()
MSFlexGrid1.DataSource = con.recordset
con.selection ("select * from medicament")
DataGrid1.DataSource = con.recordset


End Sub



Private Sub modifier_click()
v_con.connect
i = v_res.Fields.Count
For compt = 0 To i - 1
v_res.Fields(ref_iter(compt)) = Form2(ref_inter(compt)).Text
Next compt
v_res.Update
v_con.Close
End Sub

Private Sub supprimer_Click()
v_res.open
v_res.Delete
v_res.Update
v_con.Close
End Sub

form3(frmvente.frm):

Private Sub Command1_Click()
Unload Me
Load Form1
Form1.Show
End Sub


Private Sub DataGrid2_Click()
Text1 = DataGrid2.Columns(0).Value
Text2 = DataGrid2.Columns(1).Value
Text3 = DataGrid2.Columns(2).Value
End Sub

frm4(frm pharmacian.frm)

Dim con As New ClassConnexion
Dim m As String


Private Sub ajouter_click()
v_con.open
v_res.AddNew
End Sub
Public Sub modifier_click()
v_con.open
v_res.Update
End Sub
Public Sub supprimer_Click()
v_con.open
v_res.Delete
v_res.Update
v_con.Close
End Sub


Private Sub DataGrid1_Click()
text1 = DataGrid1.Columns(0).Value
text2 = DataGrid1.Columns(1).Value
text3 = DataGrid1.Columns(2).Value
text4 = DataGrid1.Columns(3).Value
text5 = DataGrid1.Columns(4).Value
text6 = DataGrid1.Columns(5).Value
text7 = DataGrid1.Columns(6).Value
text8 = DataGrid1.Columns(7).Value

End Sub





Private Sub Command2_Click()

dataEnvironement1.rsCommand1.UpdateBatch.MoveLast


End Sub

Private Sub Command3_Click()

m = MsgBox("etes vous sur de vouloir suprime", vbYesNo, "confirmation")
If m = vbYes Then
dataEnvironement1.srcommand1.Delete

End If


End Sub

Private Sub Command4_Click()
Unload Me
Load Form1
Form1.Show
End Sub

Private Sub MSFlexGrid1_Click()
MSFlexGrid1.DataSource = con.recordset
con.selection ("select * from medicament")
DataGrid1.DataSource = con.recordset


End Sub


[b]c'est un projet de gestion de pharmacie d'abord j' utilise connexion vb6 et oracle mais puisque la connexion ne marche pas , j'utilise vb6 et Access ; la connexion de la base se fait avec la data-environnement
juste le code des boutons modifier ,ajouter,supprimer
/b

merci d'avance pour vous
0
Rejoignez-nous