Friday, January 8, 2010

How to Connect SAP with Visual Basic

SAP Business One able integrates with another software development such as Visual Basic 6 and .Net.
Now, I will share to you how to connect SAP B1 using visual basic.
First you must be installing SDK SAP B1, after that you must add SAP business one DI API version on Visual basic Reference.
Below is the source code.

Public oCompany as SAPbobsCOM.Company
Public lerr As Long, sErr As String
    Set oCompany = New SAPbobsCOM.Company
    With oCompany
        .Server = your SAP Server name
        .CompanyDB = your SAP Database name
        .UserName = your SAP user
        .Password = your SAP password
        .DbServerType = dst_MSSQL2005
        .language = ln_English
        .UseTrusted = False
        .DbUserName = your SQL database user name
        .DbPassword = your SQL database password name
   
    lerr = oCompany.Connect()
        If lerr <> 0 Then
            Call oCompany.GetLastError(lerr, sErr)
            MsgBox sErr           
        Else
            Msgbox “Connected to SAP B1”
        End If
       
    End With
Note: Make sure your user id and password set correctly. System will lock your user id if you input invalid login until 3 times

No comments:

Post a Comment