473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Managing Transaction using ADO.net

Hello Everyone,
I got flexgrid with around 500 rows and 24 columns which gets populated
using data from various tables. User can change any cell values at anytime. I
want to save those values in DB at run time but I don't want to commit, till
User clicks on SAVE button and should Rollback if user clicks Cancel. In the
mean time other users should able to Query those tables.

In this case I thought, I had two options.
Option 1: was to save all new values in string variable in XML format n then
pass XML string to Store Proc in DB using DB data type Text. Which works
absoulately fine but if user changes many cell values SP sometime takes
around 4-5 seconds to update DB, which is not acceptable. Of course I m
trying to tune SP for better peformance but I dont' think it will improve
much due to amount of data I m updating or inserting.

Option 2: which is to use UPDLOCK - I had written code as follows:
Dim myConnection As SqlConnection = New SqlConnection("Data
Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;")
Dim myTrans As SqlTransaction
Dim objDR As SqlDataReader
Dim myCommand As SqlCommand
Dim sSQL As String

sSQL = "Insert into Region WITH (UPDLOCK) (RegionID,
RegionDescription) VALUES (100, 'TEST')"
myConnection.Open()
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadC ommitted)
myCommand = New SqlCommand(sSQL, myConnection)
myCommand.Transaction = myTrans
objDR = myCommand.ExecuteReader()

The problem I am facing is till I commit or rollback this transaction other
users can't query this table, which of course is not acceptable.

But if I mimic above process in SQL Query Analyzer I can write Insert/Update
Queries with UPDLOCK and can still manage to Query table in other connections.

I don't want to use NOLOCK in SQL, in order to avoid Dirty pages.

I am using SQL 2000 and Visual Studio.net(2003)

Any suggestions......Many thanks in advance.
Nov 21 '05 #1
1 1087
Since you're using ReadCommitted, I think you shouldn't need to use UPDLOCK
in your insert statements. I could be wrong though. Did you try without the
UPDLOCK in option 2?

Also, maybe this would be of some help:
http://msdn.microsoft.com/library/de...l/transact.asp
hope that helps..
Imran.
"sansaw80" <sa******@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
Hello Everyone,
I got flexgrid with around 500 rows and 24 columns which gets populated
using data from various tables. User can change any cell values at anytime. I want to save those values in DB at run time but I don't want to commit, till User clicks on SAVE button and should Rollback if user clicks Cancel. In the mean time other users should able to Query those tables.

In this case I thought, I had two options.
Option 1: was to save all new values in string variable in XML format n then pass XML string to Store Proc in DB using DB data type Text. Which works
absoulately fine but if user changes many cell values SP sometime takes
around 4-5 seconds to update DB, which is not acceptable. Of course I m
trying to tune SP for better peformance but I dont' think it will improve
much due to amount of data I m updating or inserting.

Option 2: which is to use UPDLOCK - I had written code as follows:
Dim myConnection As SqlConnection = New SqlConnection("Data
Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;")
Dim myTrans As SqlTransaction
Dim objDR As SqlDataReader
Dim myCommand As SqlCommand
Dim sSQL As String

sSQL = "Insert into Region WITH (UPDLOCK) (RegionID,
RegionDescription) VALUES (100, 'TEST')"
myConnection.Open()
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadC ommitted) myCommand = New SqlCommand(sSQL, myConnection)
myCommand.Transaction = myTrans
objDR = myCommand.ExecuteReader()

The problem I am facing is till I commit or rollback this transaction other users can't query this table, which of course is not acceptable.

But if I mimic above process in SQL Query Analyzer I can write Insert/Update Queries with UPDLOCK and can still manage to Query table in other connections.
I don't want to use NOLOCK in SQL, in order to avoid Dirty pages.

I am using SQL 2000 and Visual Studio.net(2003)

Any suggestions......Many thanks in advance.

Nov 21 '05 #2

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

Similar topics

4
by: Steven | last post by:
Hi there, I want to pass a session id from a form to a third party payment system. I have no need a of creating and maintaining sessions for the whole visit to the site. Do I just start the...
0
by: DotNetJunkies User | last post by:
I am writing a distributed transaction code. My current scenario include a client database(Suppose client- having 4 main database) which can be installed anywhere which would connect to a public...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
15
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. On a dress rehearsal run through, it failed...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
0
by: deepak | last post by:
y objective is to retrieve data from a remote server through sockets.the Maximum no of sockets that can be opened are four. The component that has to be developed in .net which must be COM...
0
by: Jaco Smuts | last post by:
Hello there question: I'm looking for information / patterns / recipe's for implementing a multi threaded program (multiple producers / consumers) that will manage transactions and maintain...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.