Skip to Content
0
Former Member
Oct 19, 2005 at 01:24 PM

Company.connect error

1328 Views

The following code snippet is being used to connect to the company:

Dim connectstr As String

Dim oCompany As SAPbobsCOM.Company

Dim lngConnect As Long

oCompany = New SAPbobsCOM.Company

oCompany.Server = SBO_Appln.Company.ServerName

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL

oCompany.CompanyDB = SBO_Appln.Company.DatabaseName

oCompany.UserName = SBO_Appln.Company.UserName

connectstr = SBO_Appln.Company.GetConnectionContext(oCompany.GetContextCookie)

Try

lngConnect = oCompany.Connect

Catch ex As Exception

MsgBox(ex.Message)

End Try

The statement "oCompany.connect" is generating the exception "Object Reference not set to an instance of an object" though a new instance of oCompany is created.