How do DOCMD.RUNSQL statements execute how to roll back?
Brief description: How does the action query executed back in a docmd.runsql statement?
problem:
How do DOCMD.RUNSQL statements execute how to roll back?
Reply:
It is hoped that the rollback operation of the transaction through DOCMD.Runsql is unfortunately, Access cannot achieve transaction's return 4 蠹 碜 碜 ⒁ 贒 贒 贒 贒 贒 帮 帮 中 中 中 中 中 中There is an option to beetransaction. This option is to confirm whether the statement is transactional. If you select True, then all operations will be treated as a separate atomic operation to operate on the database; if the choice is false, then the operation will not be treated as a transaction (in multiple users Dirty reads may appear under the way. But these transactions are completed interiors, we cannot display its operations by applying commit or rollback. According to my experience, Access cannot accomplish similar transaction display operations through DOCMD.OpenQuery. If you want to achieve a transaction, the only usage is to be implemented through WorkspaceObject.begintrans. In Access VBA Help files, you can find the following example:
'BeginBeginTransVB' To integrate this code 'replace the data source and initial catalog values' in the connection string Public Sub Main () On Error GoTo ErrorHandler' recordset and connection variables Dim Cnxn As ADODB.Connection Dim strCnxn As String Dim rstTitles As ADODB. Recordset Dim strSQLTitles As String 'record variables Dim strTitle As String Dim strMessage As String' Open connection strCnxn = "Provider = 'sqloledb'; Data Source = 'MySqlServer';" & _ "Initial Catalog = 'Pubs'; Integrated Security =' SSPI '; "Set cnxn = New ADODB.Connection Cnxn.Open strCnxn' Open recordset dynamic to allow for changes Set rstTitles = New ADODB.Recordset strSQLTitles =" Titles "rstTitles.Open strSQLTitles, cnxn, adOpenDynamic, adLockPessimistic, adCmdTable Cnxn.BeginTrans 'Loop Through RecordSet and Prompt User' to Change The Type for a Specified Title Rsttitles.Movefirst Do Until Rstitles. EOF If Trim (! RstTitles Type) = "psychology" Then strTitle = rstTitles Title strMessage = "Title:"! & StrTitle & vbCr & _ "Change type to self help?" 'If yes, change type for the specified title If MsgBox (strMessage, vbYesNo) = vbYes Then rstTitles! Type = "self_help" rstTitles.Update End If End If rstTitles.MoveNext Loop 'Prompt user to commit all changes made If MsgBox ( "Save all changes?", vbYesNo) =