Skip to Content
0
Former Member
Jul 04, 2007 at 05:54 AM

Probelm in connect To Company

11 Views

Hi All,

I am facing a problem when i am connecting to the company.. But it is not happening always.. All of sudden this exception is coming..

the Exception is ,, " Object Reference not set to an instance of an object"

The exception occurs at <b>" oCompany.Connect()[ "</b>

The code is

Private Sub ConnectToCompany()

oCompany = New SAPbobsCOM.Company

oCompany.Server = "90.180.150.115"

'oCompany.CompanyDB = "xenosproduction"

oCompany.CompanyDB = "XenosBB"

oCompany.UserName = "manager"

oCompany.Password = "manager"

oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English

oCompany.DbUserName = "sa"

oCompany.DbPassword = "sapb1@sql"

Try

<b> oCompany.Connect()</b> Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

' Check for errors during connect

oCompany.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then

MsgBox(sErrMsg)

Else

MsgBox("Connection Established", MsgBoxStyle.Information)

End If

End Sub

Pl help me on this..

Regards

Suresh R