Skip to Content

How to Reuse a SAPbobsCOM.Company connection again and again?

Nov 06, 2017 at 10:10 PM


avatar image
Former Member

I'd like to test speeds while reusing the same connection for multiple tasks (oInventoryGenExit , oInventoryGenEntry, etc.. ) compared to establishing the connection per task and disconnecting upon success..

SAPbobsCOM.Company Vcmp = new SAPbobsCOM.Company();

Vcmp.Server = "local";

Vcmp.CompanyDB = "TestDB";

Vcmp.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012;

Vcmp.DbUserName = "manger";

Vcmp.DbPassword = "password";

Vcmp.UserName = "manager";

Vcmp.Password = "password";

Vcmp.language = SAPbobsCOM.BoSuppLangs.ln_English;

Vcmp.LicenseServer = "";

Vcmp.UseTrusted = false;

int connected = Vcmp.Connect();

SAPbobsCOM.Documents oGoodsIssue = (SAPbobsCOM.Documents)Vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit);

...and so on..

note: I'm not disconnecting Vcmp at any point.

Everything works well the first attempt but I'm stuck trying to find/reference this active connection for subsequent tasks.. \

Is this possible? any sample code out there?

Thanks guys!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

DIEGO LOTHER Nov 06, 2017 at 10:45 PM

Hi Steve,

You can create your company object as static and use it where you want in your project, and just close it when you finish all your tasks.

Hope it helps.

Kind Regards,

Diego Lother

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 07, 2017 at 04:49 PM

Food for thought, I'm exploring that option. Thanks Diego,

To explain further, I have a web app (MVC) on Ipads which many ppl use simultaneously to update SAP.. My fantasy was that SAPbobscom exposed an existing open connection that i could use.

10 |10000 characters needed characters left characters exceeded