473,748 Members | 6,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQLTransaction IsolationLevel questions

Hello,

I have a subroutine similar to the following:
Private Sub RunUpdateTransa ction(ByVal UpdateSQL As String, ByVal
UpdateConn As SqlConnection)

Dim trnDedupe As SqlTransaction =
UpdateConn.Begi nTransaction(Is olationLevel.Re adCommitted, "Dedupe")

Dim cmdDedupe As New SqlCommand(Upda teSQL, UpdateConn,
trnDedupe)

Try

Dim iUpdated As Integer

iUpdated = cmdDedupe.Execu teNonQuery

trnDedupe.Rollb ack()

Catch ex As Exception
Throw ex
Finally
If Not cmdDedupe Is Nothing Then cmdDedupe.Dispo se()
End Try

End Sub

UpdateSQL looks like:

INSERT INTO MyTable1(Field1 , Field2)(SELECT Field1, Field2
FROM MyTable1 WHERE MyId1 = 123);
UPDATE MyTable2 SET MyID1 = (SELECT MAX(MyID1) FROM MyTable1)
WHERE MyID1 = 123 AND MyID2 = 456;

I have a breakpoint on trnDedupe.Rollb ack(). I then switched to Query
Analyzer and tried to run a query SELECT * FROM MyTable1 WHERE MyID1 =
(SELECT MAX(MyID1) FROM MyTable1)

I started this query before I stepped away from my desk and it's been
running for 2-1/2 hours. Should I try another type of IsolationLevel
other than ReadCommitted. It looks like ReadCommitted might be good to
prevent someone else from inserting a record into MyTable1 in between
my INSERT and UPDATE. From the documentation:
--------------------------------------------------------------------------------------
ReadUncommitted :

Shared locks are held while the data is being read to avoid dirty
reads, but the data can be changed before the end of the transaction,
resulting in non-repeatable reads or phantom data.

ReadUncommitted :

A dirty read is possible, meaning that no shared locks are issued and
no exclusive locks are honored.

RepeatableRead:

Locks are placed on all data that is used in a query, preventing other
users from updating the data. Prevents non-repeatable reads but phantom
rows are still possible.
--------------------------------------------------------------------------------------
If I'm reading the documentation correctly, it looks like I might want
to use ReadUncommitted for my testing and ReadUncommitted when I'm
using the application in production to prevent inserts between my
INSERT and UPDATE. Would any of the other IsolationLevels be useful?

Thanks,
Eric

Jun 7 '06 #1
0 1280

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2057
by: mahajan.sanjeev | last post by:
I have two SQLConnection objects having the same connection string and two corresponding SQLCommand objects for each connection object. I am using SQLTransaction with the first SQLConnection object but the second SQLConnection object does not have any SQLTransaction object. I am inserting some data using the two command objects. The problem happens when I try to do a rollback on the SQLTransaction object. The rollback happens only before...
2
2809
by: mahajan.sanjeev | last post by:
Hi, I am having problems with rollback using the SQLTransaction object. I am trying to insert records in two tables in a transaction. I want to rollback all the changes if any exception occurs in any of the inserts. But the SQLTransaction object only rolls back the inserts that happen before an exception. All inserts after the exception go through. What am I doing wrong? Is it that I cannot do any more Inserts using the transaction...
0
1081
by: mahajan.sanjeev | last post by:
Hi All, I am using a SQLTransaction in a .Net application to insert records into a SQL Server table. At one time, there are 5000 or more records to be inserted one by one. It takes some 20-25 mins for the entire process to run. Another application accesses the same table. As long as the insert process within the transaction isn't completed,
2
1386
by: perspolis | last post by:
I'm using SqlTransaction in my application.. I use sqlCommand1.BeginTransaction(IsolationLevel.ReadUncommited) when I want to update some tables with this transaction,and at the same time I'm using a sqlcommand to select some rows from those table I got Timeout Error for select command..and none of operations is done. I don't know how can I do that?? thanks in advance
0
1507
by: perspolis | last post by:
Hi all I used SqlTransaction inmy application.. SqlTransaction transact=sqlConnection1.BeginTransaction(IsoLationLevel.Something); sqlSelect.Transaction=transact; sqlInsert.Transaction=transact; ,............... but any of IsolationLevel stat I use it dosen't work properly and it works as Serializable isolation level.. When I'm using a transaction for a master-slave tables and I want when
5
451
by: Swami Muthuvelu | last post by:
Hi, I using command builder to generate my insert, update and delete statements..something like, data_adapter = New SqlClient.SqlDataAdapter(SQL, ActiveConnection) command_builder = New SqlClient.SqlCommandBuilder (data_adapter)
0
2612
by: buttslapper | last post by:
Hi, Recently we discovered in our production server this kind of exception : We are wondering what causes the transaction to be zombied, and why do we get a nullreferenceexception in this method ? As you will see in the call stack, at every 5 minutes (timer), we are inserting data in a transaction. In a day, we can have 2-3 occurence of this problème.
2
1574
by: Ryan Liu | last post by:
Hi, I have a trivial question: What does IsolationLevel mean? e.g., in SDK: ReadCommitted Shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.
2
4615
by: samuelberthelot | last post by:
Hello, I have a asp.net application in which users can create content and then save everything to a SQLServer2000 database. When they hit the save button on the form here is what I do : Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection( myconnectionstring ) Dim tx As SqlClient.SqlTransaction conn.Open()
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.