on 05-27-2016 10:22 PM
Hi,
Im currently developing some Add-ons for our company and just had a question about the connection to the database.
Im currently using the following method to open a connection to the SAP database.
oCompany = new SAPbobsCOM.Company();
oCompany = (SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany();
oCompany.Connect();
if (oCompany.Connected == true)
{
// Execute some code
}
What I have found is it takes quite some time to open this connection. I see this is an issue quite a few people have. So I think I should open the connection only once, and keep it persistent whilst the add-on is running.
I have thought about placing it in the SBO_Application_FormDataEvent, but perhaps some one has a better solution?
Regards
Hi Edward,
Access to the event you mentioned requires a UI API connection. Placing a connection on the event is a bad idea (you'll be connection everytime the event is triggered, soon you'll run out of memory).
Assuming you already have the UI API connection you can pull the company object from that connection:
try
{
var gui = new SboGuiApi();
gui.Connect(connectionString);
application = gui.GetApplication();
company = new Company { Application = application };
company.Connect();
}
catch (COMException e)
{
throw ConnectionException.CreateFrom(e);
}
Best practice to establish connection to SAP Business One is at the addon startup. Should be the very first thing you do. Store the reference to your company and application objects (perhaps in a globally accessible place) and you should be fine.
Good luck.
Best regards,
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edward,
You can refer to SAP Business One SDK Help Center or you can refer to SDK Samples for the same.
You can try to use the Single Sign On or you can go with the Classic Connection also.
Kind regards,
ANKIT CHAUHAN
SAP Business One Global Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.