﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Using TransactionKey</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 10 Sep 2026 01:16:16 GMT</lastBuildDate><ttl>20</ttl><item><title>Using TransactionKey</title><link>http://forum.strataframe.net/FindPost30923.aspx</link><description>I am unsure as to what is, &amp;nbsp;and if&amp;nbsp; it is necessary/desirable to use TransactionKeys in Transactions.&lt;br/&gt;&lt;br/&gt;&lt;font color=#2b91af size=2 face=Consolas&gt;&lt;font color=#2b91af size=2 face=Consolas&gt;&lt;font color=#2b91af size=2 face=Consolas&gt;[quote]BusinessLayer.TransactionBegin("", IsolationLevel.Serializable);&lt;br/&gt;&amp;nbsp;or &lt;br/&gt;BusinessLayer.TransactionBegin("", "WhatIsATransactionKey",IsolationLevel.Serializable);[/quote]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;font color=#000000&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;font color=#000000&gt;It looks like the TransactionKey is optional in the TransactionBegin statement, and wonder if I should use it at all. My users scenario would be that typically there could be 15-20 users accessing the same tables at the same time, and updating the same Tables, possibly updating the same Rows also at the same time&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;</description><pubDate>Wed, 15 Feb 2012 12:07:15 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Using TransactionKey</title><link>http://forum.strataframe.net/FindPost30928.aspx</link><description>Hi Ger,&lt;br/&gt;&lt;br/&gt;If I understand, the value of the update (phase #3)&amp;nbsp;is the result of a pile of processing (phase #2)&amp;nbsp;applied to the initial value acquired in phase #1. &lt;br/&gt;&lt;br/&gt;I'm pretty sure that the &lt;strong&gt;Repeatable Read&lt;/strong&gt; level would be sufficent, but not absolutely certain.&lt;br/&gt;&lt;br/&gt;In this case, I think the best isolation level would be &lt;strong&gt;Read Committed Snapshot&lt;/strong&gt;. But this level is not in all versions of SQL Server 2008 (Enterprise only, not sure). If your version doesn't support it, choose the &lt;strong&gt;Seralizable&lt;/strong&gt; level. &lt;br/&gt;&lt;br/&gt;In all cases, you don't need to name your transaction.</description><pubDate>Wed, 15 Feb 2012 12:07:15 GMT</pubDate><dc:creator>Michel Levy</dc:creator></item><item><title>RE: Using TransactionKey</title><link>http://forum.strataframe.net/FindPost30927.aspx</link><description>Hi Michel. Thanks for your reply.&lt;br/&gt;&lt;br/&gt;Do I need Transactions and Isolation level. ? Scenario is as follows, and there could be 20 simultaneous users doing the same thing:&lt;br/&gt;&lt;br/&gt;Enter a transaction which needs to update a Customer Balance with a Value&amp;nbsp; of 5. Customer Balance&amp;nbsp; &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;&lt;font style="background-color: #ffeeff"&gt;MUST&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt; be updated immediately.&lt;br/&gt;&lt;br/&gt;Customer processing&amp;nbsp;pseudo code would be as follows:&lt;br/&gt;&lt;br/&gt;[quote]1. Read the Current Customer Balance (say its currently = 100)&lt;br/&gt;2. Do a whole pile of processing which say takes 2 seconds for the sake of argument&amp;nbsp; (This bit cannot be avoided)&lt;br/&gt;3. Update the Customer Balance with the Value of 5&amp;nbsp; (Customer Balance now becomes 100 + 5 = 105)[/quote]&lt;br/&gt;&lt;br/&gt;Now unless I completely LOCK down the Customer&amp;nbsp;Record, User A would have&amp;nbsp;read the Value as being 100, and before User A has finished updating, User B comes along with a transaction value of say 8 reads the Balance also as 100. User A now updates the Customer Balance (100 + 5=105)&lt;br/&gt;&lt;br/&gt;User B now comes along and updates the Balance (100 , which&amp;nbsp;User B got , adds 7, = 107) and updates the Balance with 107&lt;br/&gt;&lt;br/&gt;This would be incorrect as the balanced should be 100 + 5 = 105&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and then&amp;nbsp; 105 + 7 = 112&lt;br/&gt;&lt;br/&gt;Other than using a Transaction (which I understand locks the Database) and Isolation Level of Serializable(Which completely locks the row from any updating at all) &amp;nbsp;, I dont know how I can accomplish my task&lt;br/&gt;&lt;br/&gt;Is there another way ?</description><pubDate>Tue, 14 Feb 2012 18:01:02 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Using TransactionKey</title><link>http://forum.strataframe.net/FindPost30924.aspx</link><description>Hi Ger,&lt;br/&gt;&lt;br/&gt;the first question is: do you really need this IsolationLevel? it is usefull only if you need a user to have an exclusive access to some tables (if you have developped in FoxPro, it's as a SET EXCLUSIVE ON). Be aware of the risk of locking everybody!&lt;br/&gt;In most cases, a simple ReadCommitted Isolation level is sufficent to manage concurrency with hundreds or thousands of users.&lt;br/&gt;&lt;br/&gt;Then the second question is: do you really need to set the transaction from the application client? remember that in SQL Server, all is allways in transaction, even if not explicitely declared (implicit transactions).&lt;br/&gt;You may need to declare a transaction from the client side, if you want to put a set of&amp;nbsp;statements on different tables in a single transaction&amp;nbsp; and you want that all are committed or all are not committed (for example, an insert in a customer table, then insert in orders table, and n insert in a orderdetails table, etc.). In such case, yes, you need to begin transaction from the client.&lt;br/&gt;&lt;br/&gt;And now, we can answer to your question: if you have a set of instructions that need to be committed in different batches, you will use named transaction inside a global transaction. this way you will be able to commit one, and rollback others.&lt;br/&gt;&lt;br/&gt;I'm not sure you need it. </description><pubDate>Tue, 14 Feb 2012 12:46:35 GMT</pubDate><dc:creator>Michel Levy</dc:creator></item></channel></rss>