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

Question about keeping transaction synchronized by usen the OleDbTransaction

Hello!

Below I have three methods it's SavePost, SavePostSetUpTableFlg and
SavePostBlowStepFlg.
I want to use transaction to keep the data synchronized. All or nothing must
be executed.

When I created the OleDbConnection and the OleDbAdapter I used the toolbox
and the wizard.
This method SavePost is just calling SavePostSetUpTableFlg and
SavePostBlowStepFlg,
Both methods SavePostSetUpTableFlg and SavePostBlowStepFlg is doing several
insert into two different tables.

Now to my question in method SavePost I have tried to implement transaction
handling in the way that I think
it should be done but I get runtime error when this statement is executing
mspLayoutAdapter.Fill( dSMspLayout ) in method SavePostBlowStepFlg
So I have a serious problem but I 'm unsure what should be done to solve it.
The run time error give a long error message but here is the first part of
it.
"System.InvalidOperationException: Execute requires the command to have a
transaction object when the connection assigned
to the command is in a pending local transaction. The Transaction property
of the command has not been initialized"

In SavePost I have this row "OleDbTransaction trx =
UTCAS.MeltPracStorage.instance.utcasMspDbConnectio n.BeginTransaction();"
this just get the OleDbTransaction from a class library that handle all
adapters and connections.
public bool SavePost(IDialogPostData post)
{
UTCAS.MeltPracStorage.instance.utcasMspDbConnectio n.Open();
OleDbTransaction trx =
UTCAS.MeltPracStorage.instance.utcasMspDbConnectio n.BeginTransaction();
try
{
SavePostSetUpTableFlg(post);
SavePostBlowStepFlg(post);
trx.Commit();
}
catch (Exception e)
{
trx.Rollback();
}
return false;
}

private void SavePostSetUpTableFlg(IDialogPostData post)
{
DataSet dSMspLayout = new DataSet();
OleDbDataAdapter mspLayoutAdapter =
MeltPracStorage.instance.mspLayoutAdapter;
MeltPracDataProcLayout mpd = post as
MeltPracDataProcLayout;

mspLayoutAdapter.SelectCommand.CommandText = "select * " +

"from MSP_LAYOUT t1 " +

"where t1.MSP_NAME = '" + mpd.PostName + "' and " +

"t1.STEELGRADE = '" + m_cboSteelGrades.SelectedItem.ToString() + "' and "
+

"t1.SAVE_TIME = " +

"(select max(SAVE_TIME) " +

"from MSP_LAYOUT " +

"where MSP_NAME = t1.MSP_NAME)";
mspLayoutAdapter.Fill( dSMspLayout );

if ( dSMspLayout.Tables[0].Rows.Count != 0 )
dSMspLayout.Tables[0].Rows[0]["ACTIVE"] = 0;

DataRow newRow = dSMspLayout.Tables[0].NewRow();
newRow["MSP_NAME"] = mpd.PostName;
newRow["ACTIVE"] = 1;
newRow["SAVE_TIME"] = mpd.SaveTime;
newRow["STEELGRADE"] = m_cboSteelGrades.SelectedItem.ToString();
int index = 0;
foreach( MeltPracDataProcLayout.SetUpTable sut in
mpd.getSetUpTableArrList() )
newRow[ Param[ index++ ] ] = sut.ParamPost;
dSMspLayout.Tables[0].Rows.Add( newRow );
mspLayoutAdapter.Update( dSMspLayout );
}

private void SavePostBlowStepFlg(IDialogPostData post)
{
DataSet dSMspLayout = new DataSet();
MeltPracDataProcLayout mpd = post as
MeltPracDataProcLayout;
OleDbDataAdapter mspBstepOrderAdapter =
MeltPracStorage.instance.mspBstepOrderAdapter;

mspBstepOrderAdapter.SelectCommand.CommandText = "select * " +
"from MSP_BSTEP_ORDER t1
" +
"where t1.MSP_NAME = '"
+ mpd.PostName + "' and " +
"t1.STEELGRADE = '"
+ m_cboSteelGrades.SelectedItem.ToString() + "' and " +
"t1.SAVE_TIME = " +
"(select max(SAVE_TIME)
" +
"from MSP_BSTEP_ORDER "
+
"where MSP_NAME =
t1.MSP_NAME)";
mspBstepOrderAdapter.Fill( dSMspLayout );

foreach( MeltPracDataProcLayout.BlowStep bs in mpd.getBlowStepArrList() )
{
DataRow nRow = dSMspLayout.Tables[0].NewRow(); // create a new
DataRow
nRow["ORDER_MSP"] = bs.Order;
nRow["MSP_NAME"] = mpd.PostName; // set from Base class
nRow["SAVE_TIME"] = mpd.SaveTime; // set from Base class
nRow["STEELGRADE"]= m_cboSteelGrades.SelectedItem.ToString();
nRow["COND_VAL"] = bs.Value;
dSMspLayout.Tables[0].Rows.Add( nRow ); // add the new row to the
dataset
}
mspBstepOrderAdapter.Update( dSMspLayout ); // insert into db
}

//Tony
Jun 16 '06 #1
0 1462

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

Similar topics

0
by: Sara | last post by:
I am getting an error that states: DB_E_ERRORSINCOMMAND when I try to establish a transaction in an Oracle 7.2 database. The code is: Try If AuthHelper.App_conn.State = ConnectionState.Closed...
0
by: AMDIRT | last post by:
I have a few questions about IssueVision (from WindowsForms) concerning its scalability and performance. Rather, if I were to implement techniques described here into another application, how...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
0
by: Eyal Cohen | last post by:
Hello, i have a windows form application and i want to use an insert command within a transaction so i satrt the transaction : ( Conn is my connection object ) System.Data.OleDb.OleDbTransaction...
2
by: Banski | last post by:
Hi, Im trying to use SELECT @@IDENTITY in a transaction. But it always returns 0. Im using an ms access database. And using the following code. What am i doing wrong? Best regards banski ...
4
by: John | last post by:
I am using ADO .Net and Access in a VB .Net app. Does MS Access support Transaction(BeginTransaction, Commit, Rollback)? Thanks.
4
by: Sin Jeong-hun | last post by:
Hi. I wrote a C# program that uses System.Data.OleDb (MS Access). For a certain operation, it calls bunch of ExecuteScalar(). The problem is, if any of those ExecuteScalar failes, then the whole...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
3
by: Gary W. Smith | last post by:
I had a couple questions about data caching. We have a site that gets a huge amount of traffic to a few specific pages that have a lot of data on them (300k hits/hour during peak, about 6-10 data...
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
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...
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
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.