on 2025 Mar 20 7:16 AM
Hi
One way to connect to Database is below . One is using Command Line. Which is the best method .
company.Server = ConfigurationManager.AppSettings["server"].ToString();
company.CompanyDB = ConfigurationManager.AppSettings["companydb"].ToString();
company.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012;
company.DbUserName = ConfigurationManager.AppSettings["dbuser"].ToString();
company.DbPassword = ConfigurationManager.AppSettings["dbpassword"].ToString();
company.UserName = ConfigurationManager.AppSettings["user"].ToString();
company.Password = ConfigurationManager.AppSettings["password"].ToString();
company.language = SAPbobsCOM.BoSuppLangs.ln_English_Gb;
company.UseTrusted = false;
company.LicenseServer = ConfigurationManager.AppSettings["licenseServer"].ToString();
connectionResult = company.Connect();
Thanks
Request clarification before answering.
Hi ramco1917,
When working with add-ons in SAP Business One, there can be 3 types of connection:
The sample you have shared, is a DI API connection. The connect which you make via Command Line, is generally a UI API connection.
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.
Hi ramco1917,
Refer to the following sample code:
1. Connect to the UI API as in a regular UI API add-on (SAP Business One must be running):
Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
SboGuiApi = New SAPbouiCOM.SboGuiApi
'// connect to a running SBO Application
If connectionString = "" Then
If Environment.GetCommandLineArgs().Length = 1 Then
sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"
Else
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
End If
Else
''connection string was filled before
End If
SboGuiApi.Connect(sConnectionString)
'// get an initialized application object
SBO_Application = SboGuiApi.GetApplication()
2. Connect to DI API using Company.GetDICompany:
Dim oCompany As SAPbobsCOM.Company
'//get DI company (via UI)
oCompany = SBO_Application.Company.GetDICompany()
---------------------------------------------------------
'// there is no need to call DI API Company.Connect method
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
User | Count |
---|---|
93 | |
11 | |
9 | |
8 | |
7 | |
5 | |
4 | |
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.