Your company is not connected because of which the other objects are not able to initialized correctly hence your getting this error.
For the condition 'ocompany.connect'
Add a condition
When oCompany.Connect does not return 0 then..
oCompany.getlasterror statement will provide you connection error.
If this is a system issue, then the DI API needs to be re installed.