Hello Ambesh,
Your code seems right but sometimes connection fails due to IP/Name configuration. Check Choose Company form within SAP Business OneClient to make sure you are giving the right values. Also could you try connecting with the below pattern?
SAPbobsCOM.Company oCompany;
oCompany = new SAPbobsCOM.Company();
oCompany.Server = "sapsrv";
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014;
oCompany.CompanyDB = "SBODemo_UK";
oCompany.UserName = "manager";
oCompany.Password = "B1Admin";
int ret = oCompany.Connect();
if (ret == 0)
MessageBox.Show("Connection ok");
else
MessageBox.Show("Connection failed: " + oCompany.GetLastErrorDescription());
Thanks,
Atilla