Connecting to a COM server
To access a method associated with a component in the COM
server, the PowerBuilder client connects to the component using
its programmatic identifier (ProgID) or its class identifier (CLSID).
You can use a tool such as OLEVIEW or the OLE tab in the PowerBuilder Browser
to view the Program ID or CLSID and methods of registered PowerBuilder
COM objects.
To establish a connection to the COM server, you need to execute
the PowerScript statements required to perform these operations:
- Declare a variable of type
OLEObject and use the Create statement to instantiate it. - Connect to the object using its Program ID or CLSID.
- Check that the connection was established.
Example The following script instantiates the EmpObj OLEObject object, connects
to the PowerBuilder COM object PB70.Employee, and checks for errors:
1 |
OLEObject EmpObj |
1 |
Integer li_rc |
1 |
EmpObj = CREATE OLEObject |
1 |
li_rc = EmpObj.ConnectToNewObject & |
1 |
("PB70.employee") |
1 |
IF li_rc < 0 THEN |
1 |
DESTROY EmpObj |
1 |
MessageBox("Connecting to COM Object Failed", & |
1 |
"Error: " + String(li_rc)) |
1 |
Return |
1 |
END IF |
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments