Skip to Content
0
Former Member
Sep 13, 2011 at 05:33 AM

Connection Problem

26 Views

Experts

For connecting to company I am using the following code

Public Class Test

Private WithEvents SBO_Application As SAPbouiCOM.Application

Private oCompany As SAPbobsCOM.Company

Public AddStarted As Boolean

Public RedFlag As Boolean

#Region "Single sign On"

Private Sub SetApplication()

AddStarted = False

RedFlag = False

Dim SboGuiApi As SAPbouiCOM.SboGuiApi

Dim sConnectionString As String

SboGuiApi = New SAPbouiCOM.SboGuiApi

sConnectionString = Environment.GetCommandLineArgs.GetValue(1)

SboGuiApi.Connect(sConnectionString)

SBO_Application = SboGuiApi.GetApplication()

End Sub

Private Function SetConnectionContext() As Integer

Dim sCookie As String

Dim sConnectionContext As String

Dim lRetCode As Integer

Try

oCompany = New SAPbobsCOM.Company

sCookie = oCompany.GetContextCookie

sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)

If oCompany.Connected = True Then

oCompany.Disconnect()

End If

Catch ex As Exception

End Try

End Function

Private Function ConnectToCompany()

ConnectToCompany = oCompany.Connect

End Function

Private Sub Class_Init()

SetApplication()

If Not SetConnectionContext() = 0 Then

SBO_Application.MessageBox("Failed setting a connection to DI API")

End

End If

If Not ConnectToCompany() = 0 Then

SBO_Application.MessageBox("Failed connecting to the company's Data Base")

End

End If

SBO_Application.MessageBox("DI Connected To: " & oCompany.CompanyName & vbNewLine & "Add-on is loaded")

End Sub

#End Region

Public Sub New()

MyBase.New()

Class_Init()

End Sub

End Class

But everytime it is going to "Failed connecting to the company's Data Base"

0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056

is the connection string used.

1. %temp% deleted

2. cookied Deleted

3. temo deleted

4. Prefetch deleted