Skip to Content
Former Member
May 19, 2004 at 09:14 AM

DI / JCo: Error using SBOBob.GetItemPrice() from webservice


I am trying to use the SBOBob.GetItemPrice() function from a webservice but it keeps raising an error when I call it. The error is:


ErrorCode: -2147417851

Message: "The server threw an exception."

Using it from the sample project '3.UsingSBObob' works fine.

Can anyone confirm if they have the same problem or better, give me a solution?


<WebMethod()> _

Public Function GetItemPriceTest() As String

Dim oCompany As SAPbobsCOM.Company = New SAPbobsCOM.Company

oCompany.Server = ConfigurationSettings.AppSettings("SBOServer")

oCompany.CompanyDB = ConfigurationSettings.AppSettings("SBODatabase")

Dim dbUserName As String = ConfigurationSettings.AppSettings("SBODBUserName")

If (dbUserName.Length > 0) Then

oCompany.UseTrusted = False

oCompany.DbUserName = dbUserName

oCompany.DbPassword = ConfigurationSettings.AppSettings("SBODBPassword")


oCompany.UseTrusted = True

End If

oCompany.UserName = ConfigurationSettings.AppSettings("SBOUserName")

oCompany.Password = ConfigurationSettings.AppSettings("SBOPassword")


oCompany.GetLastError(m_lastError, m_lastErrorMsg)

If m_lastError <> 0 Then

Throw New Exception("Error", Nothing)

End If

Dim oBridge As SAPbobsCOM.SBObob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)

Dim oRs As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

' This one raises an error

oRs = oBridge.GetItemPrice("C1000", "A1000", 100D, Now)

Return oRs.Fields.Item(0).Value & " " & oRs.Fields.Item(1).Value

End Function