public string connectCompany() { string result = "OK"; oDiCompany = new SAPbobsCOM.Company(); oDiCompany.CompanyDB = companyDb; oDiCompany.UserName = SboUID; oDiCompany.Password = SboPwd; oDiCompany.DbUserName = DbUserName; oDiCompany.DbPassword = DbPassword; //Program.oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005; if (ServerType.Trim() == "2005") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005; } else if (ServerType.Trim() == "2008") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; } else if (ServerType.Trim() == "2012") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; } else if (ServerType.Trim() == "2014") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014; } else { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; } oDiCompany.Server = SboServer; //Try to connect int lRetCode = oDiCompany.Connect(); int errCode = 0; string errMsg = ""; if (lRetCode != 0) // if the connection failed { oDiCompany.GetLastError(out errCode, out errMsg); isDIConnected = false; result = errCode + ":" + errMsg; } else { result = "OK"; isDIConnected = true; } return(result); }
public string connectCompany() { Program.objHrmsUI.oApplication.SetStatusBarMessage("Connecting to company", SAPbouiCOM.BoMessageTime.bmt_Short, false); string result = "OK"; oDiCompany = new SAPbobsCOM.Company(); oDiCompany.CompanyDB = companyDb; oDiCompany.UserName = SboUID; oDiCompany.Password = SboPwd; oDiCompany.DbUserName = DbUserName; oDiCompany.DbPassword = DbPassword; //Program.oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005; if (ServerType.Trim() == "2005") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005; } else if (ServerType.Trim() == "2008") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; } else if (ServerType.Trim() == "2012") { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; } else { oDiCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; } oDiCompany.Server = SboServer; //Try to connect int lRetCode = oDiCompany.Connect(); int errCode = 0; string errMsg = ""; if (lRetCode != 0) // if the connection failed { oDiCompany.GetLastError(out errCode, out errMsg); isDIConnected = false; result = errCode + ":" + errMsg; Program.objHrmsUI.oApplication.SetStatusBarMessage("Error in Connecting to company " + errMsg, SAPbouiCOM.BoMessageTime.bmt_Short, false); } else { Program.objHrmsUI.oApplication.SetStatusBarMessage("Company Connected", SAPbouiCOM.BoMessageTime.bmt_Short, false); result = "OK"; isDIConnected = true; } return(result); }