Description
Sets a blob field in the SAP Business One database.
NOTE: If you want to load a blob field to a file, we recommend that you use the LoadBlobFromFile method.
Syntax
Parameters
Example
| Setting a blob field (C#) | Copy Code |
|---|
string blobFilePath = @"C:\myblobfile.zip"; SAPbobsCOM.CompanyService oCompanyService = _company.GetCompanyService(); // Specify a table and blob field BlobParams oBlobParams = (BlobParams)oCompanyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams); oBlobParams.Table = "RDOC"; oBlobParams.Field = "Template"; // Specify key name and key value of a record to update BlobTableKeySegment oKeySegment = oBlobParams.BlobTableKeySegments.Add(); oKeySegment.Name = "DocCode"; oKeySegment.Value = "ACT10001"; Blob oBlob = (Blob)oCompanyService.GetDataInterface(CompanyServiceDataInterfaces.csdiBlob); // Put blob file into memory buffer FileStream oFile = new FileStream(blobFilePath, System.IO.FileMode.Open); int fileSize = (int)oFile.Length; byte[] buf = new byte[fileSize]; oFile.Read(buf, 0, fileSize); oFile.Close(); // Convert memory buffer to Base64 string string blobStr = Convert.ToBase64String(buf, 0, fileSize); // Set Base64 string to Blob object oBlob.Content = blobStr; try { // Upload Blob to B1 company database oCompanyService.SetBlob(oBlobParams, oBlob); } catch (System.Exception ex) { string errmsg = ex.Message; } |
|
See Also