on 2025 Feb 17 2:27 PM
Hi
I have below code . How to assign value to oApplication object
Hi
I have below code i am getting error - Object reference not set to an instance of the Object.
oApplication.MessageBox("Sap B1 Connected");
SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company(); oCompany.Server = "10.0.1.28:30013"; oCompany.DbServerType = BoDataServerTypes.dst_HANADB; oCompany.CompanyDB = "LIVE"; oCompany.UserName = "manager"; oCompany.Password = "123"; oCompany.language = BoSuppLangs.ln_English; oCompany.UseTrusted = true; int connectionResult = oCompany.Connect(); if (connectionResult != 0) { throw new Exception("Error connecting to SAP Business One: " + oCompany.GetLastErrorDescription()); } oApplication.MessageBox("Sap B1 Connected");
Thanks
Thank
Request clarification before answering.
Hi ramco1917,
You need to make sure that your UI API connection is successful before using oApplication. UI API connection can be made as below:
SAPbouiCOM.SboGuiApi SboGuiApi = null;
string sConnectionString = null;
SboGuiApi = new SAPbouiCOM.SboGuiApi();
sConnectionString = System.Convert.ToString( Environment.GetCommandLineArgs().GetValue( 1 ) );
SboGuiApi.Connect( sConnectionString );
SBO_Application = SboGuiApi.GetApplication( -1 );
If you want to display only the MessageBox, you can use some other option. For example:
MessageBox.Show("Connected!");
Hope it helps!
Kind regards,
ANKIT CHAUHAN
SAP Business One 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 |
---|---|
65 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.