这里以VB6.0代码为例。
一、先需要引用SDK.
二、声明一个Company对象。
1Private fCompany As SAPbobsCOM.Company
三、创建一个方法。
1Private Sub ConnectCompany()
2Set fCompany = New SAPbobsCOM.Company
3
4fCompany.CompanyDB = "sbodemo_china"
5fCompany.Server = "sapf"
6fCompany.UseTrusted = True
7fCompany.UserName = "manager"
8fCompany.Password = "manager"
9
10iRetCode = fCompany.Connect
11If (iRetCode <> 0) Then
12 MsgBox "Connect failed!"
13Else
14 MsgBox "Success to connect [" + fCompany.CompanyName + "]"
15End If
16End Sub
2Set fCompany = New SAPbobsCOM.Company
3
4fCompany.CompanyDB = "sbodemo_china"
5fCompany.Server = "sapf"
6fCompany.UseTrusted = True
7fCompany.UserName = "manager"
8fCompany.Password = "manager"
9
10iRetCode = fCompany.Connect
11If (iRetCode <> 0) Then
12 MsgBox "Connect failed!"
13Else
14 MsgBox "Success to connect [" + fCompany.CompanyName + "]"
15End If
16End Sub
四、成功连接。
其实这个过程是很简单的。