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.