Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Transazioni ADO in VB6

  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    150

    Transazioni ADO in VB6

    Dopo aver risolto tutti i problemi concernenti la connessione ad un DB protetto con password mediante ADO.Mi vedo costretto anke ad utilizzare le transazioni in quanto il mio applicativo lavorerà in rete kuindi . . .Allora le domande sono 4:

    1 cosa è una transazione
    2 Cosa mi consente di fare il metodo BeginTrans,
    3 E il CommitTrans
    4 E il RollbackTrans

    Ho inserito all'interno di una routin di vb per il salvataggio di un nuovo record nel database il seguente codice :

    On local error goto CreateError
    db.begintrans

    Rs.AddNew
    . . . . Aggiungo i record . . . .
    Rs.Update

    db.CommitTrans

    CreateError:
    db.rollbacktrans
    msgbox "La transazione non è andata a buon fine si prega di riprovare"

    La routine funziona ma non ho capito bene cosa fa e quando genera l'errore infatti questo esempio lo ho semplicmente copiuato.Grazie a tutti per l'attenzione
    Carlo Carbone

  2. #2
    c'è tutto scritto qua
    Vascello fantasma dei mentecatti nonchè baronetto della scara corona alcolica, piccolo spuccello di pezza dislessico e ubriaco- Colui che ha modificato l'orribile scritta - Gran Evacuatore Mentecatto - Tristo Mietitore Mentecatto chi usa uTonter danneggia anche te

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    150

    Risposta transazioni

    Beh nn mi è stato molto di aiuto se potresti indicarmi qualcos' altro
    Carlo Carbone

  4. #4
    Utente di HTML.it L'avatar di sebamix
    Registrato dal
    Aug 2000
    Messaggi
    1,028

    Re: Transazioni ADO in VB6

    Originariamente inviato da Carlo1984
    1 cosa è una transazione
    2 Cosa mi consente di fare il metodo BeginTrans,
    3 E il CommitTrans
    4 E il RollbackTrans
    MSDN dice:
    Use these methods with a Connection object when you want to save or cancel a series of changes made to the source data as a single unit. For example, to transfer money between accounts, you subtract an amount from one and add the same amount to the other. If either update fails, the accounts no longer balance. Making these changes within an open transaction ensures that either all or none of the changes go through.
    Note Not all providers support transactions. Verify that the provider-defined property "Transaction DDL" appears in the Connection object's Properties collection, indicating that the provider supports transactions. If the provider does not support transactions, calling one of these methods will return an error.

    After you call the BeginTrans method, the provider will no longer instantaneously commit changes you make until you call CommitTrans or RollbackTrans to end the transaction.

    For providers that support nested transactions, calling the BeginTrans method within an open transaction starts a new, nested transaction. The return value indicates the level of nesting: a return value of "1" indicates you have opened a top-level transaction (that is, the transaction is not nested within another transaction), "2" indicates that you have opened a second-level transaction (a transaction nested within a top-level transaction), and so forth. Calling CommitTrans or RollbackTrans affects only the most recently opened transaction; you must close or roll back the current transaction before you can resolve any higher-level transactions.

    Calling the CommitTrans method saves changes made within an open transaction on the connection and ends the transaction. Calling the RollbackTrans method reverses any changes made within an open transaction and ends the transaction. Calling either method when there is no open transaction generates an error.

    Depending on the Connection object's Attributes property, calling either the CommitTrans or RollbackTrans methods may automatically start a new transaction. If the Attributes property is set to adXactCommitRetaining, the provider automatically starts a new transaction after a CommitTrans call. If the Attributes property is set to adXactAbortRetaining, the provider automatically starts a new transaction after a RollbackTrans call.

    ---

    Considera che se lavori con access le transazioni sono una mezza chiavica


  5. #5

    Re: Risposta transazioni

    Originariamente inviato da Carlo1984
    Beh nn mi è stato molto di aiuto se potresti indicarmi qualcos' altro
    dubito che in 13 minuti tu l'abbia letto
    Vascello fantasma dei mentecatti nonchè baronetto della scara corona alcolica, piccolo spuccello di pezza dislessico e ubriaco- Colui che ha modificato l'orribile scritta - Gran Evacuatore Mentecatto - Tristo Mietitore Mentecatto chi usa uTonter danneggia anche te

  6. #6
    1) BEGIN apre una transazione

    2) COMMIT conferma la transazione

    3) ROLLBACK (torna indietro)
    ES: se stai inserendo dentro una tabella
    10 record...
    ed i primi 6 sono andati a buon fine (la query non ha riportato errori)
    ed il settimo(7) record presenta un errore!!!
    con ROLLBACK annulli l'INTERA operazione...
    quindi nel caso specifico (rip. nell'esempio)
    nessun record verrà scritto nella tabella (nemmeno i primi 6,
    quelli che non hanno riportati errori) e credimi, in molti casi
    le transazioni sono INDISPENSABILI.

    leggi anche qua:
    http://forum.html.it/forum/showthrea...ht=transazioni
    ...Terrible warlords, good warlords, and an english song

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.