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

"ExecuteReader request the command to have a transaction..." error occurring when the reader plainly has one.

I'm using the TableAdapterHelper to set the connection and transaction
properties on all the commands of all my typed table adapters.... I've
checked at the time of the error and all the commands have their
Transaction property set. But I still get this error when I call...

documentTA.Update(documentDS.Document[0]);

"ExecuteReader requires the command to have a transaction when the
connection assigned to the command is in a pending local transaction.
The Transaction property of the command has not been initialized."

does the tableadapter update use additional derived commands or
something?

The whole loop below:

foreach (DocumentDataSet.RequestRow requestRow in documentDS.Request)
{
using(SqlConnection conn = new
SqlConnection(Config.Instance.DatabaseConnection))
{
conn.Open();
using (SqlTransaction trans =
conn.BeginTransaction())
{
DocumentDataSetTableAdapters.DocumentTableAdapter documentTA = new
DocumentDataSetTableAdapters.DocumentTableAdapter( );

DocumentDataSetTableAdapters.RequestTableAdapter requestTA = new
DocumentDataSetTableAdapters.RequestTableAdapter() ;

DocumentDataSetTableAdapters.RequestErrorTableAdap ter requestErrorTA =
new DocumentDataSetTableAdapters.RequestErrorTableAdap ter();

TableAdapterHelper.SetTransaction(requestTA,
trans);

TableAdapterHelper.SetTransaction(requestErrorTA, trans);
TableAdapterHelper.SetTransaction(documentTA,
trans);

if (DateTime.Now >
requestRow.RequestDate.Add(Config.Instance.Handsha keTimeoutPeriod.TimeSpan))
{
requestRow.RequestStatusID =
(int)RequestStatus.Error;
CreateRequestErrorRow(documentDS,
requestRow, "CODE_FAILURE", "MSG_HANDSHAKETIME", requestErrorTA);
}
documentTA.FillByDocumentID(documentDS.Document,
requestRow.DocumentID);
if
(documentDS.Document[0].IsParentDocumentIDNull())
{
//is original registration
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
}
else
{
//is subdoc
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
documentTA.Update(documentDS.Document[0]);

//update parent

documentTA.FillByDocumentID(documentDS.Document,
documentDS.Document[0].ParentDocumentID);
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ReviewNotice;
}

documentTA.Update(documentDS.Document);
requestTA.Update(documentDS.Request);

requestErrorTA.Update(documentDS.RequestError);
trans.Commit();
}
}
}

Mar 20 '07 #1
2 17830
Martin,

You will have to show the code behind the
TableAdapterHelper.SetTransaction method. Without that, we can't see how
you are working with the transaction.

Also, have you considered using the TransactionScope class in the
System.Transactions namespace?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Martin Z" <ma***********@gmail.comwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
I'm using the TableAdapterHelper to set the connection and transaction
properties on all the commands of all my typed table adapters.... I've
checked at the time of the error and all the commands have their
Transaction property set. But I still get this error when I call...

documentTA.Update(documentDS.Document[0]);

"ExecuteReader requires the command to have a transaction when the
connection assigned to the command is in a pending local transaction.
The Transaction property of the command has not been initialized."

does the tableadapter update use additional derived commands or
something?

The whole loop below:

foreach (DocumentDataSet.RequestRow requestRow in documentDS.Request)
{
using(SqlConnection conn = new
SqlConnection(Config.Instance.DatabaseConnection))
{
conn.Open();
using (SqlTransaction trans =
conn.BeginTransaction())
{
DocumentDataSetTableAdapters.DocumentTableAdapter documentTA = new
DocumentDataSetTableAdapters.DocumentTableAdapter( );

DocumentDataSetTableAdapters.RequestTableAdapter requestTA = new
DocumentDataSetTableAdapters.RequestTableAdapter() ;

DocumentDataSetTableAdapters.RequestErrorTableAdap ter requestErrorTA =
new DocumentDataSetTableAdapters.RequestErrorTableAdap ter();

TableAdapterHelper.SetTransaction(requestTA,
trans);

TableAdapterHelper.SetTransaction(requestErrorTA, trans);
TableAdapterHelper.SetTransaction(documentTA,
trans);

if (DateTime.Now >
requestRow.RequestDate.Add(Config.Instance.Handsha keTimeoutPeriod.TimeSpan))
{
requestRow.RequestStatusID =
(int)RequestStatus.Error;
CreateRequestErrorRow(documentDS,
requestRow, "CODE_FAILURE", "MSG_HANDSHAKETIME", requestErrorTA);
}
documentTA.FillByDocumentID(documentDS.Document,
requestRow.DocumentID);
if
(documentDS.Document[0].IsParentDocumentIDNull())
{
//is original registration
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
}
else
{
//is subdoc
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
documentTA.Update(documentDS.Document[0]);

//update parent

documentTA.FillByDocumentID(documentDS.Document,
documentDS.Document[0].ParentDocumentID);
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ReviewNotice;
}

documentTA.Update(documentDS.Document);
requestTA.Update(documentDS.Request);

requestErrorTA.Update(documentDS.RequestError);
trans.Commit();
}
}
}

Mar 20 '07 #2
On Mar 19, 10:51 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Martin,

You will have to show the code behind the
TableAdapterHelper.SetTransaction method. Without that, we can't see how
you are working with the transaction.

Also, have you considered using the TransactionScope class in the
System.Transactions namespace?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Martin Z" <martin.zar...@gmail.comwrote in message

news:11*********************@n76g2000hsh.googlegro ups.com...
I'm using the TableAdapterHelper to set the connection and transaction
properties on all the commands of all my typed table adapters.... I've
checked at the time of the error and all the commands have their
Transaction property set. But I still get this error when I call...
documentTA.Update(documentDS.Document[0]);
"ExecuteReader requires the command to have a transaction when the
connection assigned to the command is in a pending local transaction.
The Transaction property of the command has not been initialized."
does the tableadapter update use additional derived commands or
something?
The whole loop below:
foreach (DocumentDataSet.RequestRow requestRow in documentDS.Request)
{
using(SqlConnection conn = new
SqlConnection(Config.Instance.DatabaseConnection))
{
conn.Open();
using (SqlTransaction trans =
conn.BeginTransaction())
{
DocumentDataSetTableAdapters.DocumentTableAdapter documentTA = new
DocumentDataSetTableAdapters.DocumentTableAdapter( );
DocumentDataSetTableAdapters.RequestTableAdapter requestTA = new
DocumentDataSetTableAdapters.RequestTableAdapter() ;
DocumentDataSetTableAdapters.RequestErrorTableAdap ter requestErrorTA =
new DocumentDataSetTableAdapters.RequestErrorTableAdap ter();
TableAdapterHelper.SetTransaction(requestTA,
trans);
TableAdapterHelper.SetTransaction(requestErrorTA, trans);
TableAdapterHelper.SetTransaction(documentTA,
trans);
if (DateTime.Now >
requestRow.RequestDate.Add(Config.Instance.Handsha keTimeoutPeriod.TimeSpan)*)
{
requestRow.RequestStatusID =
(int)RequestStatus.Error;
CreateRequestErrorRow(documentDS,
requestRow, "CODE_FAILURE", "MSG_HANDSHAKETIME", requestErrorTA);
}
documentTA.FillByDocumentID(documentDS.Document,
requestRow.DocumentID);
if
(documentDS.Document[0].IsParentDocumentIDNull())
{
//is original registration
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
}
else
{
//is subdoc
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ActionReq;
documentTA.Update(documentDS.Document[0]);
//update parent
documentTA.FillByDocumentID(documentDS.Document,
documentDS.Document[0].ParentDocumentID);
documentDS.Document[0].DocumentStatusID =
(int)DocumentStatus.ReviewNotice;
}
documentTA.Update(documentDS.Document);
requestTA.Update(documentDS.Request);
requestErrorTA.Update(documentDS.RequestError);
trans.Commit();
}
}
}- Hide quoted text -

- Show quoted text -
Figured it out. The TableAdapterHelper sets all the commands
transactions... but the .Update() command doesn't use an existing
command, it dynamically builds one. This, of course, means that the
transaction is not set on that command. So I'm using manual SQL
statements instead of Update.

I should be using a transaction scope, but the server does not have
the distributed transaction coordinator enabled, and I can't figure
out how to get transaction scopes to work without one.

Mar 21 '07 #3

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

Similar topics

10
by: Jay Chan | last post by:
I keep getting the following error message when I run a serie of SQL commands: Server: Msg 9002, Level 17, State 6, Line 15 The log file for database 'tempdb' is full. Back up the transaction...
0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
1
by: Jean-Marc Blaise | last post by:
Dear all, It seems to me the IY54968 apar (V8.2) does not correct totally the problem: db2start db2 connect to sample db2 get snapshot for db on sample | grep "oldest transaction" ==> What...
4
by: Julia | last post by:
Hi, I have upload my ASP.NET application to my IIS 6.0 server and whenever i try to get a aspx page i get "The request is not supported. " in return when i try to get a .txt file which is in...
1
by: Trygve Lorentzen | last post by:
Hi, my webservice is running on Win2000 SP4, IIS 5.0 fully patched, connecting to a MySQL database and mainly returning Typed DataSet's from webmethods. After running for a while, generally a...
3
by: Loane Sharp | last post by:
Hi there I use the FileStream object to download a zip file over the internet to my local disk. The file downloads successfully, but when I attempt to unzip it, I'm told that the file is in use...
7
by: EManning | last post by:
Using A2003. I'm receiving this error when returning from a "DoCmd.OpenReport..." statement. I have a tab control with a subform on every tab. The user selects an item from a combobox at the top...
1
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I have written a Web Service that works with my test harness written using VS2005. However, a client to the service consistently receives a "Bad Request (Invalid Header Name)" response for each...
5
by: workingstiff19 | last post by:
I just want people to click on a link to download a file. I've done it before, but this is a new computer and I must be missing something. (Possibly an Apache configuration setting?) Here is...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...
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...

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.