Transaction IsolationLevel problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hardy Wang

    Transaction IsolationLevel problem

    Hi all,
    I have an application, which requires several SQL activities, so I wrap
    them in a transaction:
    SqlConnection conn = new SqlConnection(c onnectionString );
    conn.Open();
    SqlTransaction tran = conn.BeginTrans action(Isolatio nLevel.ReadUnco mmitted);

    I use MS Application Block for Data Access to handle all SQL statements:
    SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);

    I have following 2 problems:
    1) When I debug this application from my local machine, in the middle of
    this transaction, I cannot use my Sql Query Analyzer to do anything against
    some tables used in this transaction, even though I set transaction's
    isolation level to read uncommitted. Until I finish my debugging, result
    will return from query analyzer.

    2) I have a common class, and it contains a function shared by some other
    functions,
    public bool Audit(SqlTransa ction tran) {
    string sql = "insert into AuditTable ....";
    try {
    SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
    return true;
    } catch (Exception ex) {
    return false;
    }
    }
    Every other function passes its own transaction object to this function.
    I frequently find dead lock caused by sql statement in this function. Is
    there any limitation to use transaction object across classes? The other
    funny thing is, the audit table is used to be inserted only, no other piece
    of code will read/write to this table, so how comes this relative
    independent table will cause dead lock?

    Welcome to any comment.

    Thanks!

    --
    WWW: http://hardywang.1accesshost.com
    ICQ: 3359839
    yours Hardy


  • Val Mazur \(MVP\)

    #2
    Re: Transaction IsolationLevel problem

    Hi Hardy,

    Check IsolationLevel property after you opened transaction. Is it still
    ReadUncommited after transaction was opened?
    --
    Val Mazur
    Microsoft MVP





    "Hardy Wang" <hardywang@hotm ail.com> wrote in message
    news:%23zHdS1oS FHA.3184@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    > Hi all,
    > I have an application, which requires several SQL activities, so I wrap
    > them in a transaction:
    > SqlConnection conn = new SqlConnection(c onnectionString );
    > conn.Open();
    > SqlTransaction tran =
    > conn.BeginTrans action(Isolatio nLevel.ReadUnco mmitted);
    >
    > I use MS Application Block for Data Access to handle all SQL
    > statements:
    > SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
    >
    > I have following 2 problems:
    > 1) When I debug this application from my local machine, in the middle of
    > this transaction, I cannot use my Sql Query Analyzer to do anything
    > against some tables used in this transaction, even though I set
    > transaction's isolation level to read uncommitted. Until I finish my
    > debugging, result will return from query analyzer.
    >
    > 2) I have a common class, and it contains a function shared by some other
    > functions,
    > public bool Audit(SqlTransa ction tran) {
    > string sql = "insert into AuditTable ....";
    > try {
    > SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
    > return true;
    > } catch (Exception ex) {
    > return false;
    > }
    > }
    > Every other function passes its own transaction object to this
    > function. I frequently find dead lock caused by sql statement in this
    > function. Is there any limitation to use transaction object across
    > classes? The other funny thing is, the audit table is used to be inserted
    > only, no other piece of code will read/write to this table, so how comes
    > this relative independent table will cause dead lock?
    >
    > Welcome to any comment.
    >
    > Thanks!
    >
    > --
    > WWW: http://hardywang.1accesshost.com
    > ICQ: 3359839
    > yours Hardy
    >[/color]


    Comment

    • Hardy Wang

      #3
      Re: Transaction IsolationLevel problem

      Yes, I am sure isolation level is still ReadUncommitted .

      --
      WWW: http://hardywang.1accesshost.com
      ICQ: 3359839
      yours Hardy
      "Val Mazur (MVP)" <group51a@hotma il.com> wrote in message
      news:OGKN%23urS FHA.2556@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > Hi Hardy,
      >
      > Check IsolationLevel property after you opened transaction. Is it still
      > ReadUncommited after transaction was opened?
      > --
      > Val Mazur
      > Microsoft MVP
      >
      > http://xport.mvps.org
      >
      >
      >
      > "Hardy Wang" <hardywang@hotm ail.com> wrote in message
      > news:%23zHdS1oS FHA.3184@TK2MSF TNGP14.phx.gbl. ..[color=green]
      >> Hi all,
      >> I have an application, which requires several SQL activities, so I
      >> wrap them in a transaction:
      >> SqlConnection conn = new SqlConnection(c onnectionString );
      >> conn.Open();
      >> SqlTransaction tran =
      >> conn.BeginTrans action(Isolatio nLevel.ReadUnco mmitted);
      >>
      >> I use MS Application Block for Data Access to handle all SQL
      >> statements:
      >> SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
      >>
      >> I have following 2 problems:
      >> 1) When I debug this application from my local machine, in the middle of
      >> this transaction, I cannot use my Sql Query Analyzer to do anything
      >> against some tables used in this transaction, even though I set
      >> transaction's isolation level to read uncommitted. Until I finish my
      >> debugging, result will return from query analyzer.
      >>
      >> 2) I have a common class, and it contains a function shared by some other
      >> functions,
      >> public bool Audit(SqlTransa ction tran) {
      >> string sql = "insert into AuditTable ....";
      >> try {
      >> SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
      >> return true;
      >> } catch (Exception ex) {
      >> return false;
      >> }
      >> }
      >> Every other function passes its own transaction object to this
      >> function. I frequently find dead lock caused by sql statement in this
      >> function. Is there any limitation to use transaction object across
      >> classes? The other funny thing is, the audit table is used to be inserted
      >> only, no other piece of code will read/write to this table, so how comes
      >> this relative independent table will cause dead lock?
      >>
      >> Welcome to any comment.
      >>
      >> Thanks!
      >>
      >> --
      >> WWW: http://hardywang.1accesshost.com
      >> ICQ: 3359839
      >> yours Hardy
      >>[/color]
      >
      >[/color]


      Comment

      • Val Mazur \(MVP\)

        #4
        Re: Transaction IsolationLevel problem

        Then it looks like a bug. I will try to check if this the same on my PC

        --
        Val Mazur
        Microsoft MVP





        "Hardy Wang" <hardywang@hotm ail.com> wrote in message
        news:upGfJeySFH A.2872@TK2MSFTN GP14.phx.gbl...[color=blue]
        > Yes, I am sure isolation level is still ReadUncommitted .
        >
        > --
        > WWW: http://hardywang.1accesshost.com
        > ICQ: 3359839
        > yours Hardy
        > "Val Mazur (MVP)" <group51a@hotma il.com> wrote in message
        > news:OGKN%23urS FHA.2556@TK2MSF TNGP12.phx.gbl. ..[color=green]
        >> Hi Hardy,
        >>
        >> Check IsolationLevel property after you opened transaction. Is it still
        >> ReadUncommited after transaction was opened?
        >> --
        >> Val Mazur
        >> Microsoft MVP
        >>
        >> http://xport.mvps.org
        >>
        >>
        >>
        >> "Hardy Wang" <hardywang@hotm ail.com> wrote in message
        >> news:%23zHdS1oS FHA.3184@TK2MSF TNGP14.phx.gbl. ..[color=darkred]
        >>> Hi all,
        >>> I have an application, which requires several SQL activities, so I
        >>> wrap them in a transaction:
        >>> SqlConnection conn = new SqlConnection(c onnectionString );
        >>> conn.Open();
        >>> SqlTransaction tran =
        >>> conn.BeginTrans action(Isolatio nLevel.ReadUnco mmitted);
        >>>
        >>> I use MS Application Block for Data Access to handle all SQL
        >>> statements:
        >>> SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
        >>>
        >>> I have following 2 problems:
        >>> 1) When I debug this application from my local machine, in the middle of
        >>> this transaction, I cannot use my Sql Query Analyzer to do anything
        >>> against some tables used in this transaction, even though I set
        >>> transaction's isolation level to read uncommitted. Until I finish my
        >>> debugging, result will return from query analyzer.
        >>>
        >>> 2) I have a common class, and it contains a function shared by some
        >>> other functions,
        >>> public bool Audit(SqlTransa ction tran) {
        >>> string sql = "insert into AuditTable ....";
        >>> try {
        >>> SqlHelper.Execu teNonQuery(tran , CommandType.Tex t, sql);
        >>> return true;
        >>> } catch (Exception ex) {
        >>> return false;
        >>> }
        >>> }
        >>> Every other function passes its own transaction object to this
        >>> function. I frequently find dead lock caused by sql statement in this
        >>> function. Is there any limitation to use transaction object across
        >>> classes? The other funny thing is, the audit table is used to be
        >>> inserted only, no other piece of code will read/write to this table, so
        >>> how comes this relative independent table will cause dead lock?
        >>>
        >>> Welcome to any comment.
        >>>
        >>> Thanks!
        >>>
        >>> --
        >>> WWW: http://hardywang.1accesshost.com
        >>> ICQ: 3359839
        >>> yours Hardy
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        Working...