03-04-24 11:39 AM
Hi,
i am trying to add binary type column in collection but i am getting below error.
Internal : Could not execute code stage: Conversion from type 'Byte()' to type 'String' is not valid.
Below is sample code
var dt = new DataTable();
dt.Columns.Add("Column1",typeof(Byte[]));
dt.Rows.Add(File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg"));
outParam=dt;
03-04-24 11:44 AM
i am using Blueprism trail version 7.2.1.7446 (x64) and .net version is 4.8.9181.0
03-04-24 11:52 AM
when i try to store in Binary data item instead of in Collection it is working fine.
Below are sample screenshots.
03-04-24 01:09 PM
Hi Naveen,
Could you please try this code
// Create a new DataTable
var dt = new DataTable();
// Add a column to the DataTable
dt.Columns.Add("Column1", typeof(Byte[]));
// Read the bytes from the image file and add them to the DataTable
byte[] imageBytes = File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg");
dt.Rows.Add(imageBytes);
// Assign the DataTable to the output parameter
outParam = dt;
03-04-24 02:49 PM
@faheemsd - Thanks for reply.
I tried your code but no luck same error only i am getting.
04-04-24 07:47 AM
Hi Naveen,
Could you please try this?
byte[] imageBytes = File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg");
BinaryDataItem binaryDataItem = new BinaryDataItem(imageBytes);
outParam = binaryDataItem;
04-04-24 08:15 AM
Page: Initialise
Stage: Code2
Type: Error
Action: Validate
Description: Compiler error at line 4: The type or namespace name 'BinaryDataItem' could not be found (are you missing a using directive or an assembly reference?)
Repairable: No
10-04-24 01:15 AM
dt.Rows.Add() is used to add a new DataRow object instance to the dt (DataTable) rows collection. You need to create a DataRow instance first, populate it with your binary data, and then add that instance to the DataTable Rows collection.
Here's one way to do it:
var dt = new DataTable();
dt.Columns.Add("Column1",typeof(Byte[]));
DataRow dr = dt.NewRow();
dr["Column1"] = File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg");
dt.Rows.Add(dr);
outParam=dt;
Cheers,
Eric
13-04-24 02:50 PM
@ewilson - I tried your code but i am getting same error only. same code working in BP version 6.10.5 or lower version. the problem is only with BP version 7.2.1
15-04-24 04:21 PM
I just tested it in BP v7.3 and it works exactly as shown, assuming your VBO is configured for C# and not VB.NET. Have you recently restarted your BP instance and machine? If not, you might try that.
Cheers,
Eric