473,383 Members | 1,846 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,383 software developers and data experts.

c# transactions in 2.0 intermittently differs from 1.1?

Hello
I'm making an update in c# ASP.NET 2.0 using the OleDb provider for
SQL Server.
I have an existing application running on 1.1 that works fine. Now I
want to convert it to 2.0.
My problem is that within the transaction, a read after an update/
insert will read the old commited values. The IsolationLevel I have
checked, it is ReadCommited (however I really should be reading MY OWN
changed values???). I've tried with IsolationLevel.Serializable but to
no help.

This is what I do:

I have a table testTable that has Id, Name and Step as columns.

OleDbConnection dbconn = new OleDbConnection("Provider=SQLOLEDB.
1;Password=xxx;Persist Security Info=True;OLE DB Services=-7;OLE DB
Services=-2;User ID=xxx;Initial Catalog=MyDb;Data Source=iit003;Use
Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use
Encryption for Data=False;Tag with column collation when
possible=False;pooled=false;");

dbconn.Open();
OleDbTransaction trans = dbconn.BeginTransaction();
OleDbCommand dbRead1 = new OleDbCommand("SELECT STEP FROM
TestTable WHERE ID = 1", dbconn, trans);
string res1 = dbRead1.ExecuteScalar().ToString();

OleDbCommand dbComm = new OleDbCommand("UPDATE
TestTable SET STEP = STEP + 1, NAME=? WHERE ID = 1", dbconn, trans);
dbComm.Parameters.Add(new
System.Data.OleDb.OleDbParameter("Name",
System.Data.OleDb.OleDbType.VarChar, 14,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "Name", System.Data.DataRowVersion.Current,
null));

dbComm.Parameters["Name"].Value = "Jojo";
int iAffected = dbComm.ExecuteNonQuery();

OleDbCommand dbRead2 = new OleDbCommand("SELECT STEP
FROM TestTable WHERE ID = 1", dbconn, trans);
string res2 = dbRead2.ExecuteScalar().ToString();
<==== THIS READS THE OLD VALUE!!!!
trans.Commit();
dbconn.Close();
Another funny thing is that after a reboot it works ok for a while. I
also haven't been able to reproduce this in a Windows Forms
application, only in ASP.Net.

Any ideas?

Best regards
Johan

Mar 27 '07 #1
2 1408
This has been reproduced on another computer as well.
I don't know whether it's a bug in our development environment (virus
applications etc.) however I do find it strange that there is no
exceptions thrown even though the Commit obviously fails.
/ Johan

Apr 17 '07 #2
On 17 Apr, 15:48, a95jo...@hotmail.com wrote:
This has been reproduced on another computer as well.
I don't know whether it's a bug in our development environment (virus
applications etc.) however I do find it strange that there is no
exceptions thrown even though the Commit obviously fails.
/ Johan
I've given up now. Killing aspnet_wp.exe and a restart of the IIS
seems to solve the issue that to me seems to be related to the
debugger. Annoying.

May 10 '07 #3

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

Similar topics

7
by: Richard Maher | last post by:
Hi, I am seeking the help of volunteers to test some software that I've developed which facilitates distributed two-phase commit transactions, encompassing any resource manager (e.g. SQL/Server...
3
by: Iain Mcleod | last post by:
I wish to do a series of inserts on a sql server database in the context of a transaction. The inserts will be done as a series of stored procedure calls. I wish to be able to rollback any...
6
by: Terri | last post by:
I have a table called Transactions with 3 fields: ID, Date, and Amount. Each ID can have multiple transactions in one particular year. An ID might not have had any transactions in recent years. ...
9
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
11
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few...
1
by: mark | last post by:
In Java, you can use JBoss or similar to host EJB that will manage your transactions for you. You could, of course, write your own transactions using JDBC. In .NET, we can specify our own...
0
radcaesar
by: radcaesar | last post by:
Customer Table ID Name Address City Phone 1 Vijay Stores 6,Gandhi Road Pondy 0413-276564 2 Ram Stores 3, MG Road, Pondicherry 0413-29543756 3 Balu Papers 3, RG...
2
by: Sridhar | last post by:
Hi, I am trying to implement sql transactions. But I am not knowing how to do that. I created a data access layer which contains methods to select/insert/update tables in a database. I have also...
12
by: Rami | last post by:
I have some requirement for an automated payment system. The system has four machines setup as follows: 1- Two machines have a clustered database. 2- Two machines have a .net business logic...
3
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.