cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove row from matrix and MSSQL DB in one user moment ?

Former Member
0 Kudos

If someone have working code sample, how to remove row from matrix and at once in MSSQL DB in one user moment, please public him in your answer.

Thank you !!!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for the help

former_member185682
Active Contributor
0 Kudos

You're welcome.

Don't forget if my answer solved your problem, click on accept button below my answer, if no, try if possible share your solution to help others users with a similar difficulty.

Kind Regards,

Diego Lother

Former Member
0 Kudos

My apologies, i forgot to specify that mentioned matrix is a part of a user form which is not regestered as UDO. I learned from description what GeneralService provides access only to UDOs. So how to remove row in matrix witch belongs Form(MyForm: UserFormBase) ?

former_member185682
Active Contributor
0 Kudos

Hi Евгений,

Yes, GeneralService is for work with UDO. If in this case is not an UDO, I suppose you use an UDT, then use the second block code that was provided in my first answer.

Kind Regards,

Diego Lother

former_member185682
Active Contributor
0 Kudos

Hi Евгений,

Depends what type is your data. But you need to call:

oMtx.DeleteRow(line);

and call the correct method to delete your register.

Suppose that your line represents a register from UDO, you can do something like this:

            SAPbobsCOM.GeneralService oGeneralService = null;
            SAPbobsCOM.GeneralData oGeneralData = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams = null;


            try
            {
                oGeneralService = SBO_Company.GetCompanyService().GetGeneralService("your udo ucode");
                oGeneralParams = oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);
                oGeneralParams.SetProperty("Code", code);
                oGeneralService.Delete(oGeneralParams);
            }
            finally
            {
                this.ReleaseObject(oGeneralService);
                this.ReleaseObject(oGeneralData);
            }

Suppose that your line represents a register from an UDT, you can do something like this:

            SAPbobsCOM.UserTable oUserTable = null;
            try
            {
                oUserTable = GatiApplicationEx.Instance.SBO_Company.UserTables.Item(this.TableName());
                //Verifies if exist in the table  
                if (oUserTable.GetByKey(this.Code.ToString()))
                {
                    //if exists , remove it.  
                    if (oUserTable.Remove() != 0)
                    {
                        sucess = false;
                        throw new Exception(SBO_Company.GetLastErrorDescription());
                    }
                }
            }
            finally
            {
                this.ReleaseObject(oUserTable);
            }

Hope it helps.

Kind Regards,

Diego Lother