What do you need to do in order to connect to sap business one from c#?
First of all you need to know which version of the API do you want to use and does API is 32bit or 64bit.
The API is called "DI API" and can be found on the same server where you did the SAP installation in the same directory.
For example, DI API version 100 is located in
Before you actually can use the API you need to register the SAP Com object. Inside "DI API" directory you will find a file "SAPbobsCOM100.dll" (for version 100) and register it with
%systemroot%\System32\regsvr32.exe C:\DI API 100\SAPbobsCOM100.dll
Once we have the COM object we can start coding. A basic object which is used for connection is called "Company"
static void Main(string[] args) { Company oCompany = new Company(); oCompany.Server = "Sap-10-Sql"; oCompany.language = BoSuppLangs.ln_English; oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2019; oCompany.CompanyDB = "MyCompanyDb"; oCompany.UserName = "admin"; oCompany.Password = "pass"; oCompany.DbUserName = "sa"; oCompany.DbPassword = "pass"; oCompany.UseTrusted = false; var lRetCode = oCompany.Connect(); if (lRetCode == 0) Console.WriteLine("Done"); string sErrMsg = string.Empty; oCompany.GetLastError(out lRetCode, out sErrMsg); Console.WriteLine(sErrMsg); oCompany.Disconnect(); }
"Server" is the DB server and not an application server.
oCompany.LicenseServer = "sap-10-app:40000"; oCompany.SLDServer = "sap-10-app:30010";
or you can do it in the conf file. In the same location where "DI API 100" folder is located, search for the folder called "Conf". Inside the conf directory open the file b1-local-machine.xml and modify the following values