on 09-08-2008 9:05 AM
Trying to connect DI from UI API.
private SAPbobsCOM.Company oCompany;
private SAPbouiCOM.Application SBO_Application;
// '''''''''''''''''
// Connect to SBO '
// '''''''''''''''''
private void SetApplication() {
SAPbouiCOM.SboGuiApi SboGuiApi = null;
string sConnectionString = null;
SboGuiApi = new SAPbouiCOM.SboGuiApi();
sConnectionString = System.Convert.ToString( Environment.GetCommandLineArgs().GetValue( 1 ) );
SboGuiApi.Connect( sConnectionString );
SBO_Application = SboGuiApi.GetApplication( -1 );
}
// '''''''''''''''''''''''''''''''''
// Connect with connection string '
// '''''''''''''''''''''''''''''''''
private int SetConnectionContext() {
int setConnectionContextReturn = 0;
string sCookie = null;
string sConnectionContext = null;
int lRetCode = 0;
oCompany = new SAPbobsCOM.Company();
sCookie = oCompany.GetContextCookie();
sConnectionContext = SBO_Application.Company.GetConnectionContext( sCookie );
if ( oCompany.Connected == true ) {
oCompany.Disconnect();
}
setConnectionContextReturn = oCompany.SetSboLoginContext( sConnectionContext );
return setConnectionContextReturn;
}
// '''''''''''''''''
// Connect to SBO '
// '''''''''''''''''
private int ConnectToCompany() {
int connectToCompanyReturn = 0;
// Establish the connection to the company database.
connectToCompanyReturn = oCompany.Connect();
return connectToCompanyReturn;
}
// '''''''''''''''''
// Init the Class '
// '''''''''''''''''
public Test() : base() {
SetApplication();
if ( !( SetConnectionContext() == 0 ) ) {
SBO_Application.MessageBox( "Failed setting a connection to DI API", 1, "Ok", "", "" );
System.Environment.Exit( 0 ); // Terminating the Add-On Application
}
if ( !( ConnectToCompany() == 0 ) ) {
SBO_Application.MessageBox( "Failed connecting to the company's Data Base", 1, "Ok", "", "" );
Application.Exit(); // Terminating the Add-On Application
}
SBO_Application.MessageBox( "DI Connected To: " + oCompany.CompanyName, 1, "Ok", "", "" );
// events handled by SBO_Application_ItemEvent
bool tmpB = false;
SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler( SBO_Application_ItemEvent );
}
But Getting error "Failed to connect company" . Why??
What is the value returned by the function ConnectToCompany ?
It will give u some -ve number.If u search that number in the help center u can fild solution in it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello...
I´m with the same problem, but the return code is -131
I try to find in the SDK Help Center, but i´m not found the errors list.
Can same one help me, please?
Tks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
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.