Results 1 to 2 of 2

Thread: Page level transactions

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Posts
    37

    Page level transactions

    I am trying to define a simple transaction at page level but it is
    failling. I have added a reference to System.EnterpriseServices and on the page I have set these directives:

    <%@ Page Language="vb" Transaction="Required" ... %>
    <%@ Assembly Name="System.EnterpriseServices.dll" %>
    <%@ Import Namespace="System.EnterpriseServices" %>

    In a button, on the code-behind module I have:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim cn As OleDbConnection
    Dim cm As OleDbCommand

    Try

    'open connection here

    cm = New OleDbCommand()
    With cm
    .Connection = cn
    .CommandType = CommandType.Text
    .CommandText = "INSERT INTO tb_ccg(id_ccg, num_ccg)
    VALUES (1, '21')"
    .ExecuteNonQuery()

    'Table name is wrong
    .CommandText = "INSERT INTO tb_ccgss(id_ccg, num_ccg) VALUES (2,'32')"
    .ExecuteNonQuery()
    End With
    ContextUtil.SetComplete()

    Catch Ex As Exception
    ContextUtil.SetAbort()

    Finally
    cn.Close()
    End Try

    On the second command, the table name is wrong, so I need that all the commands be aborted. But the first command is executed while the second is not. Am I missing something?

    Thanks,

    Robert

  2. #2
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322
    Check to see if you had done 2 things

    1) Inherit the ServicedComponent Class into your appropriate class. Then you will have full implementation of the COM+ application service component.

    2) Add this attribute before the transactional unction call
    <Transaction(TransactionOption.Required)>
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width