on 05-26-2010 2:47 PM
Hi
I want to ad a blob object into master data line table.
My table is @CT_PF_CMG1.
this is my code
CompanyService ocomp = connection.GetCompany().GetCompanyService();
BlobParams param = ocomp.GetDataInterface(CompanyServiceDataInterfaces.csdiBlobParams) as BlobParams;
param.Table = "@CT_PF_CMG1";
param.Field = "U_Description"; //This fild is used to store base64 string ? if so what type has it be ?
BlobTableKeySegment seg = param.BlobTableKeySegments.Add();
seg.Name = "Code"; //is this correct this is document lines table
seg.Value = "qwe";
BlobTableKeySegment seg2 = param.BlobTableKeySegments.Add();
seg2.Name = "LineId";//is this correct this is document lines table
seg2.Value = "1";
Blob oblob = ocomp.GetDataInterface(CompanyServiceDataInterfaces.csdiBlob) as Blob;
string base64;
using (System.IO.FileStream fs=new System.IO.FileStream(filename,System.IO.FileMode.Open ))
{
long fsize = fs.Length;
byte[] buf = new byte[fsize];
fs.Read(buf, 0, (int)fsize);
fs.Close();
base64 = Convert.ToBase64String(buf);
}
oblob.Content = base64;
try
{
ocomp.SetBlob(param,oblob);
}catch(Exception ex)
{
}
it throws an error
"CCompanyServices::SetBlob Cannot update database; no records found."
Thanks for an advice .
Michal,
Have a look at the GetBlob Method in the SAP Business One SDK Help as there is sample code there that you can review. Also, I am assuming you are using Business One 8.8 as Blob was introduced in version 8.8.
Eddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edward
Unfortunately, these Help files don`t help me a lot.
Basically I have two questions.
1).Is the variable "Field" holds an object in base64, if so, what should be the type? Memo?
2) If it is a table of data lines having two key fields LineNum and DocEntry whether the following code is correct.
BlobTableKeySegment seg = param.BlobTableKeySegments.Add();
seg.Name = "DocEntry";
seg.Value = "1";
BlobTableKeySegment seg2 = param.BlobTableKeySegments.Add();
seg2.Name = "LineNum";
seg2.Value = "1";
Thanks for quick reply
User | Count |
---|---|
85 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.