dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Intermediate
Jul 28, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


SetCommandsTransaction - Assign a transaction to the DataAdapter's commands

' Assign the same transaction to the Update/Delete/Insert commands of all the 
' OleDb/SqlAdapters passed in input
' Note: all the DataAdapters must be of the same type (OleDb or Sql)
' Note: requires Imports System.Data.OleDb and Imports System.Data.SqlClient
'
' Example: SetCommandsTransaction(tran, da1, da1)

Sub SetCommandsTransaction(ByVal tran As IDbTransaction, _
    ByVal ParamArray adapters() As IDataAdapter)
    If adapters.Length = 0 Then Return
    If TypeOf adapters(0) Is OleDbDataAdapter Then
        Dim daOledb As OleDbDataAdapter
        For Each daOledb In adapters
            If Not daOledb.UpdateCommand Is Nothing Then _
                daOledb.UpdateCommand.Transaction = tran
            If Not daOledb.InsertCommand Is Nothing Then _
                daOledb.InsertCommand.Transaction = tran
            If Not daOledb.DeleteCommand Is Nothing Then _
                daOledb.DeleteCommand.Transaction = tran
        Next
    ElseIf TypeOf adapters(0) Is SqlDataAdapter Then
        Dim daSql As SqlDataAdapter
        For Each daSql In adapters
            If Not daSql.UpdateCommand Is Nothing Then _
                daSql.UpdateCommand.Transaction = tran
            If Not daSql.InsertCommand Is Nothing Then _
                daSql.InsertCommand.Transaction = tran
            If Not daSql.DeleteCommand Is Nothing Then _
                daSql.DeleteCommand.Transaction = tran
        Next
    End If
End Sub
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date