WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Access

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Winbatch - Access 2000 Advanced DML Transactions - This Example Demonstrates the Advanced SQL in the Jet 4.0 Provider

Keywords: 	 Advanced SQL in the Jet 4.0 Provider example

Winbatch - Access 2000 Advanced DML Transactions

The sample cty.mdb includes two tables, Codes and Codesbackup (which are identical). The script below illustrates the Advanced SQL in the Jet 4.0 Provider, specifically to BEGIN, Execute, then either COMMIT or ROLLBACK Transactions

NOTE: these commands are not available in Access or DAO, and should not be mixed with ADO Transaction functions.

Stan Littlefield December 20, 2002


; ///////////////////////////////////////////////////////
; Winbatch - Access 2000 Advanced DML Transactions
; The sample cty.mdb includes two tables, Codes and Codesbackup
; (which are identical). The script below illustrates the
; Advanced SQL in the Jet 4.0 Provider, specifically to BEGIN,
; Execute, then either COMMIT or ROLLBACK Transactions
;
; NOTE: these commands are not available in Access or DAO, and
;       should not be mixed with ADO Transaction functions.
;
; Stan Littlefield December 20, 2002
; ///////////////////////////////////////////////////////

src   = StrCat( DirGet(),"CTY.MDB" )
If ! FileExist( src ) Then Exit
IntControl( 72,1,0,0,0 )

BoxOpen("Performing Access Transaction Processing","Opening %src%")
cConn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%src%"
DB    = ObjectOpen("ADODB.Connection")
DB.Open(cConn)


cSQL = "BEGIN TRANSACTION;"
DB.Execute(cSQL)

cSQL = "DELETE * FROM Codes WHERE Dialcode>'59999';"
DB.Execute(cSQL)

; o.k. so the delete command has been issued
; do we want to change our mind?

result = AskYesNo( "Rows Have Been Deleted", "Do You Want To Permantly Remove Them?")

If result == @YES
   ; data is gone per query.
   cSQL = "COMMIT TRANSACTION;"
   DB.Execute(cSQL)
   goto end
Endif

:oops
; data will not be permanently deleted
cSQL = "ROLLBACK TRANSACTION;"
DB.Execute(cSQL)

:end
DB.Close()
ObjectClose( DB )
BoxShut()
Exit

:Cancel
Goto oops

Download city.mdb and zip file:
access2000trans.zip

Article ID:   W15616
File Created: 2017:08:29:11:58:44
Last Updated: 2017:08:29:11:58:44