M
Martin Z
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.RequestErrorTableAdapter requestErrorTA =
new DocumentDataSetTableAdapters.RequestErrorTableAdapter();
TableAdapterHelper.SetTransaction(requestTA,
trans);
TableAdapterHelper.SetTransaction(requestErrorTA, trans);
TableAdapterHelper.SetTransaction(documentTA,
trans);
if (DateTime.Now >
requestRow.RequestDate.Add(Config.Instance.HandshakeTimeoutPeriod.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();
}
}
}
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.RequestErrorTableAdapter requestErrorTA =
new DocumentDataSetTableAdapters.RequestErrorTableAdapter();
TableAdapterHelper.SetTransaction(requestTA,
trans);
TableAdapterHelper.SetTransaction(requestErrorTA, trans);
TableAdapterHelper.SetTransaction(documentTA,
trans);
if (DateTime.Now >
requestRow.RequestDate.Add(Config.Instance.HandshakeTimeoutPeriod.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();
}
}
}