cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to V2004A

Former Member
0 Kudos

I was programming with V6.5 but now I need to convert to V2004A. How do I do this?

I know that I need to add.

pApps.AddonIdentifier = "4CC5B8A4E0213A68489E38CB4052855EE8678CD237F64D1C11C22707A54DBD2D5D5F6E4050A09B9F9FB80FAC44F6"

But do I need to change this?

pApps.Connect "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"

Accepted Solutions (0)

Answers (2)

Answers (2)

barend_morkel2
Active Contributor
0 Kudos

Hi Laura.

If your message returns that you are connected to a company, then you did not disconnect properly when you killed the App previously. What you must do is check if your Compnay object is connected using the ".connected" property on the object - if so - disconnect and only then attempt to connect

Former Member
0 Kudos

Hello Barend,

Thanks for the advice. I tested my connection and it is false.

When the program pass through these two line I get the same error. At the first line the pCompany.Connect value is 0. Now when I give value to 1RetCode the pCompany.Connect value is -116. Why is this? Can you Help?

 
pCompany.UseTrusted = True

' Log on SAP Business One database.
lRetCode = pCompany.Connect

Former Member
0 Kudos

Hope this helps,

This is my copnnecitoncodes, works fine.

Note I dont really use a AddOn identifier yet on this. the functiuon reads a blank line, but you will need after tha 31/12/2005 a valid one I understand.


Public Sub Main()
On Error GoTo theerr
        
    Set gObjSboGuiApi = New SAPbouiCOM.SboGuiApi
    
    Set gObjCompany = New SAPbobsCOM.Company
    
    '---set the add on identifier by reading from a file
    gObjSboGuiApi.AddonIdentifier = GetAddOnIdentifier
        
    '// connect string provided in project properties
    gObjSboGuiApi.Connect command
    
'
'    '// connect to the DI using single sign on
    Call gObjAtt_Generic.ConnectWithSingleSignOn
       
Exit Sub
theerr:
    MsgBox Err.Description, vbInformation, CONST_STR_APP_NAME
End Sub


Public Function ConnectWithSingleSignOn() As Boolean
    On Error GoTo theerr
    Dim strCookie As String
    Dim strConnStr As String
    Dim lngRetval As Long
    
    strCookie = gObjCompany.GetContextCookie
    strConnStr = mobjSBOApplication.Company.GetConnectionContext(strCookie)

    lngRetval = gObjCompany.SetSboLoginContext(strConnStr)
    If Not lngRetval = 0 Then
        '---operation failed
        Err.Raise 500 + vbObjectError, CONST_STR_APP_NAME & "ConnectWithSingleSignOn", "gObjCompany.SetSboLoginContext(strConnStr) : Failed"
    End If

    lngRetval = gObjCompany.Connect
    
    Dim lErrCode As Long
    Dim sErrMsg As String
    If lngRetval <> 0 Then
        gObjCompany.GetLastError lErrCode, sErrMsg
        Err.Raise lErrCode, CONST_STR_APP_NAME & "ConnectWithSingleSignOn", sErrMsg
    End If
Exit Function
theerr:
    Err.Raise Err.Number, Err.Source, Err.Description & vbCrLf & " Function: Connedt With Single Sign On "
        
End Function

Indika.

barend_morkel2
Active Contributor
0 Kudos

Hi Laure,

Where did you get the add-on identifier from (how did you create it?)?

Former Member
0 Kudos

Administration | Licence | Add On Identifier Generator

Indika.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

To work with the AddOn identifier:

While you are in development mode you click on the Developpement type to create the AddOnIdentifier.

Once you want to deliver the code to a customer you need a LicenseKeyName to generate and AddOnIdentifier using the Solution type.

The AddOnIdentifier will be mandatory starting on 01/01/2006!!!

To obtain a licenseKeyName you need to create a customer message on the component: SBO-BC-LIKEY

Hope it helps

Trinidad.

barend_morkel2
Active Contributor
0 Kudos

That is exactly what I was trying to confirm with Laura.

Former Member
0 Kudos

There are two very useful SAP notes with regards to this topic of creating add-on and delploying it.

search for following notes.

816222

838327

Indika.

rasmuswulff_jensen
Active Contributor
0 Kudos

You don't need to change it but you should not send the connectionstring hardcoded to the connect-method "0030002C0030002C005300ect...". Put it rather as a command line argument because when you make real real addon (ard + exe) the client will send a connectionstring to your addon

Former Member
0 Kudos

I tried that and it send to work better but now I get Errcode -116 Already connected to a company database.

What am I doing wrong??


Sub Main()

    Set pApps = New SboGuiApi
    DEBUG_MODE = True
    If DEBUG_MODE = True Then
'        pApps.Connect "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"
       'connect for runtime
        pApps.Connect Command
    End If
    
    pApps.AddonIdentifier = "4CC5B8A4E0213A68489E38CB4052855EE8678CD237F64D1C11C22707A54DBD2D5D5F6E4050A09B9F9FB80FAC44F6"
    
    Set frm = New Form1
    frm.Visible = False
    Load frm
    
    'Connect to SBODemo_US using DI API
    Call BOBSConnect
    
    Set pEve = New EventHandler
    Set pApp = pEve.applic
   ' Set frm = Nothing
    

End Sub

Public Sub BOBSConnect()

' Define variables.
Dim pCompany As SAPbobsCOM.Company
Dim lRetCode As Long
Dim sErrMsg As String

' Initialize the Company Object.
' You must create this first to enable connection to the company database.
Set pCompany = New SAPbobsCOM.Company

' Set the mandatory connection properties.
pCompany.Server = "TEMP2K"                'Name of the DB Server
pCompany.CompanyDB = "Laura_Brewer_DB"    'Enter the name of your company DB
pCompany.UserName = "manager"             'Enter the B1 user name
pCompany.Password = "manager"             'Enter the B1 password
pCompany.language = ln_English            'Enter the logon language

' Use Windows authentication for database server.
' True for NT server authentication,
' False for database server authentication.
pCompany.UseTrusted = True

' Log on SAP Business One database.
lRetCode = pCompany.Connect

' Check result code.
' To continue, the result code must be 0.
' Otherwise, check the error code and its related error message.
If lRetCode <> 0 Then
            pCompany.GetLastError lRetCode, sErrMsg
End If
End Sub