samahabab7
Messages postés9Date d'inscriptionsamedi 7 avril 2012StatutMembreDernière intervention 8 mai 2014
-
11 mai 2012 à 19:07
samahabab7
Messages postés9Date d'inscriptionsamedi 7 avril 2012StatutMembreDerniè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
samahabab7
Messages postés9Date d'inscriptionsamedi 7 avril 2012StatutMembreDerniè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
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
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
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