6
Answers

Object reference not set to an instance of the Object.

Ramco Ramco

Ramco Ramco

6d
53
1

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

Answers (6)