Probleme valider BDD

cs_khier Messages postés 19 Date d'inscription dimanche 23 mars 2003 Statut Membre Dernière intervention 31 mars 2009 - 21 sept. 2008 à 06:58
nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 - 21 sept. 2008 à 18:29
salut
je suis debutant en visuel basic , jai creer une programme avec base de donne access
mais le probleme a chaque fois valider les enregistrement je trouve cette message:
( vous avez essayer de valider ou d'annuler une transaction sans debuter de de transaction au préalable)
voila la fonction enregistrer:
Private Sub cmdsave_Click()
    On Error GoTo err
    Dim bm
    If validate() = False Then Exit Sub
   
  
    With Data1.rsUL
        If (.State = adStateClosed) Then: .Open
        If (modstate = False) Then: .AddNew
       .Fields("Num_L") = txtt_code.Text
        .Fields("Adresse") = txtt_name.Text
        .Fields("Ville") = Txt_ville.Text
        If txtisbn.Text = "" Then
            .Fields("Cartes") = Null
        Else
            .Fields("Cartes") = txtisbn.Text
        End If
        .Fields("Tel") = txtt_tel.Text
        .Fields("Fax") = txtFax.Text
        .Fields("Nbr_synd") = txt_nbrs.Text
        ' concatenate the fractional part to the price amount
  '      .Fields("Finances") = txtprice.Text & "." & txtdigits.Text
        .Update
        ' if purchasesform is open then reflect the changes in the form
        ' regarding the title name, price etc.
        If purchasesformisopen Then
            With Data1.rspurchases
                If .RecordCount > 0 Then bm = .Bookmark
                Set frmpurchases.DataGrid1.DataSource = Nothing
                .Close
                .Open
                Set frmpurchases.DataGrid1.DataSource = Data1
                If .RecordCount > 0 Then .Bookmark = bm
            End With
        End If
        If salesformisopen Then
            With Data1.rssales
                If .RecordCount > 0 Then bm = .Bookmark
                Set frmsales.DataGrid1.DataSource = Nothing
                .Close
                .Open
                Set frmsales.DataGrid1.DataSource = Data1
                If .RecordCount > 0 Then .Bookmark = bm
            End With
        End If
        If modstate = False Then
            If titlesformisopen Then
                .Close
                .Open
                Set frmtitles.DataGrid1.DataSource = Data1
                If (.Filter <> adFilterNone) Then
                    .Filter = adFilterNone
                    frmtitles.cmdremfilter.Enabled = False
                End If
                .Find .Fields(0).Name & "='" & txtt_code.Text & "'"
            End If
            If MsgBox("Do you want to add a new record?", vbQuestion + vbYesNo + vbDefaultButton1) = vbYes Then
                cmdreset_Click
                txtt_code.Text = makecode()
            Else
                If Not titlesformisopen Then
                    .Close
                Else
                    If frmtitles.cmdDelete.Enabled = False Then frmtitles.enablecontrols True
                End If
                Unload Me
            End If
        Else
            ' close and open of the recordset is necessary for refreshing the
            ' recordset as it is based on a query which will be invoked against the
            ' changed records only if it is reopened
            Set frmtitles.DataGrid1.DataSource = Nothing
            .Close
            .Open
            .Find .Fields(0).Name & "='" & txtt_code.Text & "'"
            Set frmtitles.DataGrid1.DataSource = Data1
            Unload Me
        End If
    End With
    Data1.conn.CommitTrans
    Exit Sub
err:
    Data1.conn.RollbackTrans                        ' point arret l'erreur
    If titlesformisopen Then
        Set frmtitles.DataGrid1.DataSource = Nothing
        Data1.rsUL.CancelUpdate
        Set frmtitles.DataGrid1.DataSource = Data1
    Else
        Data1.rsUL.CancelUpdate
    End If
    MsgBox err.Description, vbCritical, "Error"
End Sub
aider moi svp   

4 réponses

lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 sept. 2008 à 17:18
S.L.B.
<hr />
C'est au pied du mur qu'on voit mieux le mur... 
0
lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 sept. 2008 à 17:31
Bonjour,
Je recommence : Tu es bien en vb6???
Dim bm --> Qu'est ce que c'est????
validate()--> fonction qui renvoi un boolèen mais qui fait quoi?
Data1.conn.RollbackTrans--> Le rollbacktrans j'ai jamais vu
Quand tu fais un pas à pas pourquoi tu passe tout de suite sur ton goto??? à quel moment?
SLB.
0
lillith212 Messages postés 1229 Date d'inscription vendredi 16 novembre 2007 Statut Membre Dernière intervention 16 juin 2009
21 sept. 2008 à 17:40
ReBonjour,

Question : Pourquoi avoir reposter un sujet alors que tu avais ouvert le meme???
Question : As-tu fait attention aux remarques qui t'ont été faite???
En effet tu as posté ton code mais il me semble que dedenet2 t'a posé des questions... Questions auquelles bien sur tu n'as pas répondu...
Bon coding
0
nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 37
21 sept. 2008 à 18:29
Salut,

Il te manque le Data1.conn.Begintrans
Pour commencer la transaction c'est plus pratique de la commencer avec de la commiter
0
Rejoignez-nous