Axapta DynAx = new Axapta();
AxaptaRecord DynRec;
string strUserName = "";
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("", "");
string tableName = "";
DynAx.LogonAs(strUserName.Trim(), "", nc, dataAreaId, "en-us","", "");
try
{
using (DynRec = DynAx.CreateAxaptaRecord(tableName))
{
var binData = DynAx.CreateAxaptaObject("Bindata");
var loaded = binData.Call("loadFile", path);
var data = binData.Call("getData");
AxaptaContainer axc = DynAx.CreateAxaptaContainer();
axc.Add(data);
DynRec.set_Field("ATTACHMENT", axc.get_Item(1));
// Commit the record to the database.
DynRec.Insert();
}
}
catch (Exception ex)
{
return false;
}
finally
{
DynAx.Logoff();
}
對Ax進行身份驗證,從Axe Bindata類中獲取容器並保存記錄。
Thanks Maxim, 容器是正確的選擇。 正確初始化AxaptaContainer的方法是在Axapta類中調用CreateAxaptaContainer方法。 –
您能否提供一些示例代碼,以便我可以更新答案以供將來參考? –
我會發布完整的代碼最大。 –