Skip to Content
avatar image
Former Member

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

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 !!!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Feb 13, 2017 at 03:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 14, 2017 at 10:03 AM

    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) ?

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Feb 16, 2017 at 08:02 AM

    Thanks for the help

    Add comment
    10|10000 characters needed characters exceeded

    • 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