cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with oMatrix.LoadFromDataSource()

Former Member
0 Kudos
127

Hi all,

As I am new in SBO world, I'm trying to change a form adding a new tab with a new matrix. Well, I have a problem when I try to bind my Matrix with data from SBO database.

The code line "oMatrix.LoadFromDataSource();" get the following error:

{System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

at SAPbouiCOM.IMatrix.LoadFromDataSource()

at SysForm.SystemForm.AddItemsToTESTE(ItemEvent pVal) in C:Program FilesSAPSAP Business One SDKSamplesCOM UICSharp11.SystemFormManipulationSystemForm.cs:line 289}

Here is my code:

SAPbouiCOM.IColumn oColumn = null;

SAPbouiCOM.DBDataSource oDBDataSource;

SAPbouiCOM.DBDataSource oDBDataSource1;

SAPbouiCOM.DBDataSource oDBDataSource2;

SAPbouiCOM.DBDataSource oDBDataSource3;

SAPbouiCOM.IItem ioItem;

SAPbouiCOM.Matrix oMatrix;

oDBDataSource = oOrderForm.DataSources.DBDataSources.Add("AITM");

oItem = oOrderForm.Items.Item("38");

ioItem = oOrderForm.Items.Add("Matrix", SAPbouiCOM.BoFormItemTypes.it_MATRIX);

ioItem.Left = oItem.Left;

ioItem.Top = oItem.Top + 50;

ioItem.Height = oItem.Height - 50;

ioItem.Width = oItem.Width;

ioItem.FromPane = 101;

ioItem.ToPane = 101;

oMatrix = ((SAPbouiCOM.Matrix)(ioItem.Specific));

oMatrix.Layout = SAPbouiCOM.BoMatrixLayoutType.mlt_Normal;

oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto;

oColumn = oMatrix.Columns.Add("col0", SAPbouiCOM.BoFormItemTypes.it_EDIT);

oColumn.Editable = false;

oColumn.ForeColor = 1;

oColumn.TitleObject.Caption = "#";

oColumn = oMatrix.Columns.Add("CardCode", SAPbouiCOM.BoFormItemTypes.it_EDIT);

oColumn.Width = 30;

oColumn.Description = "col1";

oColumn.TitleObject.Caption = "Código";

oColumn.DisplayDesc = false;

oColumn.DataBind.SetBound(true, "AITM", "ItemCode");

oColumn = oMatrix.Columns.Add("ItemCode", SAPbouiCOM.BoFormItemTypes.it_EDIT);

oColumn.Width = 30;

oColumn.Description = "col2";

oColumn.TitleObject.Caption = "Nome";

oColumn.DisplayDesc = false;

oColumn.DataBind.SetBound(true, "AITM", "ItemName");

oMatrix.Clear();

oMatrix.AutoResizeColumns();

oDBDataSource.Query(null);

oMatrix.LoadFromDataSource();

--

Thanks for your response,

Best regards,

Joana Silva

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What is your target to accomplish?

Former Member
0 Kudos

I'm just learning how I can change forms.

My goal is: create a new tab with a matrix and bind it with data from SBO database.

Now I checked the code line oDBDataSource.Query(null); and the number of fields and lines are correct.

Former Member
0 Kudos

The data source must be consistent with the form you are working on. It is not that free that you can add any source.

Former Member
0 Kudos

Got it!

Thanks Gordon.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Joana Silva,

Welcome you post on the forum.

Are you trying to bind CardCode with AITM.ItemCode and ItemCode with AITM.ItemName? That is not possible.

Thanks,

Gordon

Former Member
0 Kudos

Hi Gordon,

thank you for your answer.

Where I have written "CardCode" and "ItemCode" are the columns ID right? They are just a reference, I guess.

I refer the table field here:

oColumn.DataBind.SetBound(true, "AITM", "ItemCode");

Thanks,

Joana

Former Member
0 Kudos

AITM is difficult to bind because Primary Key Columns are more than one. One ItemCode may have multiple log instances.

Former Member
0 Kudos

I tried with OCRC table, it only has one PK column, and the error continues!