Updating Data Using The Business Connector

Good Morning All,

I am having an issue with updating AX 2009 data using the .net business connector,.

I wrote a class, with in the class I have a update methods that i pass the data and the axapta connect object into,.

the first time i use the method the update is processed. but all other updates will not process (No Errors) until i restart the debugger,

all reads (selects) with as they should its just the updates.

I am starting to wonder if a bug exists, but can not find any reference to this.

  1. the connection is opened once and stays open until im done.

  2. I test to make sure i find the record i want to update, and yes it is found each time.

any insight would be great

Thanks again

Chris

Hi,

Can you show the code?

Regards,

arnam

I can, it follows the msdn example closely but not exact.

I have redesigned the class and now close the connection after updates and it works correctly now. So i feel this is a bug in the business connector. maybe we dont have the latest service pack / updates,

public bool UpdateStatus(Axapta axconn)
{
if (_IsDirty)
{
if (axconn.Session().ToString().Length > 0)
{
using (AxaptaRecord UpdateJobStatus = axconn.CreateAxaptaRecord(“CreditAutomationJobStatus”))
{
axconn.TTSBegin();
UpdateJobStatus.ExecuteStmt(string.Format(“select forupdate * from %1 where %1.ServiceID == ‘{0}’”, _ServiceID));
UpdateJobStatus.set_Field(“ServiceID”, _ServiceID);
UpdateJobStatus.set_Field(“LastCheckin”, DateTime.Now.ToString());
UpdateJobStatus.set_Field(“ServiceStatus”, _Status);
UpdateJobStatus.set_Field(“RunTime”, _lastRuntime.ToString());
UpdateJobStatus.set_Field(“LastRun”, _EndTime.ToString());
if (UpdateJobStatus.Found)
{
UpdateJobStatus.Update();
}
else
{
UpdateJobStatus.Insert();
}
axconn.TTSCommit();
UpdateJobStatus.Dispose();
_IsDirty = false;
return true;
}
}
}
return true;
}

I use very similar code and it’s working every time without reconnecting:

[…]

netConnector.DynAx.TTSBegin();

using (AxaptaRecord axRecord = netConnector.DynAx.CreateAxaptaRecord(“TableName”))
{

axRecord.ExecuteStmt(String.Format(“select forupdate * from %1 where %1.FieldName== {0}”, FieldValue));

if (axRecord.Found)
{

axRecord.set_Field(“FieldName2”, fieldValue2);
axRecord.Update();

ret = true;
}
}

netConnector.DynAx.TTSCommit();

…the only difference is that open the session before calling a select.

Morning, You mean the ttsbegin? I originally had it at the top and at the close, still the same problem. With the same code working with only changing the section that opens and closes the connection, Leads me to believe our system may not be fully patched on our development system., Do you know what version and patch level your system is at? Thanks Chris

Yes, I mean transaction (ttsbegin) not session :slight_smile:

Kernel / Application version: 5.0.1500.6491

Patch: HFRU7