Transactions Error: DEF_TRANS_KEY has not been started


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Does this additional code help?

private void AssignBatchID(String pBatchID)
{
   
// attach the batch number to only the selected invoice records
   
for (int i = 0; i < invselection.SelectedCount; i++)
    {
       
InvoicesCurrentBO mCurrInvoice = (InvoicesCurrentBO)invselection.GetSelectedRow(i);
       
InvoiceMasterBO mInvMasterBO = new InvoiceMasterBO();
        mInvMasterBO.FillByPrimaryKey(mCurrInvoice.invoiceindex);
       
if (mInvMasterBO.Count > 0)
        {
            mInvMasterBO.Edit();
            mInvMasterBO.batchid = pBatchID;
            mInvMasterBO.Save();
        }
    }
}

I am thinking that the Save() method needs to reflect transactions, like this: mInvMasterBO.Save(true).

If I replace that method parameter whereever a save occurs inside that transaction, will that fix the error?

Bill


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here is my code:

private void UpdateAspireForTransfer()
{
    try
    {
       
BusinessLayer.TransactionBegin("Aspire", IsolationLevel.ReadCommitted);
       
// Retrieve the next Batch ID
       
String mBatchID = GetNextBatchID();
        AssignBatchID(mBatchID);
        CreateCommissions(mBatchID);
       
BusinessLayer.TransactionCommit("Aspire");
        UpdateDynamicsForTransfer(mBatchID);
    }
    catch
    {
       
BusinessLayer.TransactionRollback("Aspire");
       
throw;
    }
}

For some reason, yet unknown to me, the TransactionRollBack gets called and generates an error:

A transaction with the key [DEF_TRANS_KEY] has not been started.

and this stack trace:

at MicroFour.StrataFrame.Data.DbDataSourceItem.TransactionEnd(String TransactionKey, Boolean IsCommit)
at MicroFour.StrataFrame.Data.DbDataSourceItem.TransactionRollback(String TransactionKey)
at MicroFour.StrataFrame.Business.BusinessLayer.TransactionRollback(String DataSourceKey)
at Aspire.Accounting.Invoicing.UpdateAspireForTransfer()
at Aspire.Accounting.Invoicing.TransferTSB_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

So, what am I doing wrong?

Thanks, for straightening me out,
Bill


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search