Developing Matt

My Technical Journal

Committing transactions in code

leave a comment »

I’ve always committedd/rolled back my transactions in my sql statements.  This morning mitch introduced me to the SqlTransaction object.  Thanks mitch!

Public Sub Test()

        Dim cn As New SqlConnection

        Dim cmd As SqlCommand

        Dim Tran As SqlTransaction


            Tran = cn.BeginTransaction

            For Each s As String In Now.ToString

                cmd = New SqlCommand(“insert”, cn)

                cmd.Transaction = Tran




        Catch ex As Exception




        End Try

End Sub



Written by matt

June 3, 2008 at 8:36 am

Posted in,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: