on 04-10-2017 11:41 AM - last edited on 02-03-2024 11:08 PM by postmig_api_4
using System;
using System.Collections.Generic;
using System.Xml;
using SAPbouiCOM.Framework;
namespace SBOAddonProject_B1Connect
{
[FormAttribute("SBOAddonProject_B1Connect.Form1", "Form1.b1f")]
class Form1 : UserFormBase
{
private SAPbouiCOM.EditText CFL_CMP;
private SAPbouiCOM.EditText User;
private SAPbouiCOM.EditText pwd;
private SAPbouiCOM.Button BTNChange;
private SAPbouiCOM.Button Button1;
private SAPbouiCOM.StaticText StaticText0;
private SAPbouiCOM.StaticText StaticText1;
private SAPbouiCOM.StaticText StaticText2;
public SAPbobsCOM.Company otherCompany = new SAPbobsCOM.Company();
public Form1()
{
otherCompany.Server = Program.oCompany.Server;
otherCompany.CompanyDB = Program.oCompany.CompanyDB;
otherCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_HANADB;
otherCompany.DbUserName = Program.oCompany.DbUserName;
otherCompany.DbPassword = Program.oCompany.DbPassword;
otherCompany.language = SAPbobsCOM.BoSuppLangs.ln_English;
}
public override void OnInitializeComponent()
{
this.CFL_CMP = ((SAPbouiCOM.EditText)(this.GetItem("CFL_CMP").Specific));
this.User = ((SAPbouiCOM.EditText)(this.GetItem("User").Specific));
this.pwd = ((SAPbouiCOM.EditText)(this.GetItem("pwd").Specific));
this.BTNChange = ((SAPbouiCOM.Button)(this.GetItem("BTNChange").Specific));
this.BTNChange.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.BTNChange_ClickBefore);
// this.Button0.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.Button0_ClickBefore);
this.Button1 = ((SAPbouiCOM.Button)(this.GetItem("2").Specific));
this.StaticText0 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_5").Specific));
this.StaticText1 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_6").Specific));
this.StaticText2 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_7").Specific));
this.OnCustomInitialize();
}
private void BTNChange_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
{
BubbleEvent = true;
//BubbleEvent = true;
otherCompany.UserName = User.ToString();
otherCompany.Password = pwd.ToString();
string error = string.Empty;
int iErr;
if (otherCompany.Connect() != 0 )
{
Program.oCompany.GetLastError(out iErr, out error);
if (iErr == -111)
{
Application.SBO_Application.MessageBox("Wrong database password");
}
else if (iErr == -107)
{
Application.SBO_Application.MessageBox("Wrong company password");
}
else
{
Program.SBO_Application.StatusBar.SetText(""+Program.oCompany.GetLastErrorDescription()+ Program.oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
}
}
else
{
//Connected
Program.SBO_Application.StatusBar.SetText("Connected", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
}
}
}
}
And Getting Error 'the function requires all threads to run'
Hi Dhruv,
This line should'nt work:
otherCompany.DbPassword = Program.oCompany.DbPassword;
The SDK doesn't provide the password of the database user.
Did you try to replace the lines:
otherCompany.DbUserName =Program.oCompany.DbUserName;
otherCompany.DbPassword =Program.oCompany.DbPassword;
By the instruction:
otherCompany.UseTrusted = true;
Hope it helps.
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DIEGO LOTHER
Thank you for resopons not work still ..... Getting same error when initialize ('the function requires all threads to run')
'otherCompany.CompanyDB =Program.oCompany.CompanyDB;' at left hand side in .Net and SDK will give me DBName when i logged in B1 also password but look like ******** when it initialized.
Hi Dhruv,
Try to login to DTW for the affected company for which you are getting the error and collect all required parameters in order to make the connection in DTW. After that try the same with DI API.
In this piece of code, can you try to enter LicenseServer or SLDServer property and check the connection?
oCompany.SLDServer = "https://<Server-name>:40000/"
You will be able to use SLDServer property, if you will be using 9.2 PL05 or above.
Hope it helps.
Kind regards,
ANKIT CHAUHAN
SAP SME Support
Hi Dhruv,
The password look like "******" because the SDK doesn't provide the password for security reasons. In this case when you need connect on the database with another user, I suggest to use the property UseTrusted = true.
P.S: I provide a more detailed response on your second post.
Hope it helps.
Kind Regards,
Diego Lother
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.