Skip to Content

Is it better to keep a Company.Connect() open or should I use one per transaction?

Performancewise and resourcewise, what's better?

Right now, I open and close the connection every time I want to post a transaction (like an object.update or object.add) but I am not really sure if this is considered a bad practice. I do it this way because I don't like to keep a connection open while the add-on is alive... but I want to know which one is considered a best practice

Company.Connect() at the start of the Add-On and Company.Disconnect() before closing it

vs

Companny.Connect() <DoSomething> Company.Disconnect()

I hope you guys and gals can enlight me 😊

EDIT

I am using SAP Business One 9.1 over SQL Server 2012.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Aug 11, 2016 at 01:17 AM

    Hi Hector,

    Connecting to SBO has a very high overhead.

    I would keep the connection open through all the session.

    If you addon is connected to a running SBO, you can use the company connection of the SBO addon instead of connecting your self.

    oCompany = SBOApplication.Company.GetDICompany as SAPbobsCOM.Company;

    Regards

    Edy

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.