OLE Problem - FRM-40992 An OLE error occured: 0x80004002
585864Feb 18 2009 — edited Nov 23 2010Dear All
We have Weigh Scale Attached to PC
I am trying to read data from COM port
When i try to read com port it showing folloing error
FRM-40992 An OLE error occured: 0x80004002
Code is as:
Declare
CommHandle ole2.obj_type; -- to hold the interface pointer
hold number;
NUM1 number;
string1 Varchar2(2000);
string2 OleVar;
Begin
CommHandle := forms_ole.get_interface_pointer('block3.OLE_CONTROL4');
Message(CommHandle);Message(CommHandle);
OLE2.SET_PROPERTY(CommHandle, 'CommPort', 1);
--num1:=Get_Ole_Num(CommHandle,4);
--Num1:=OLE2.GET_num_PROPERTY(CommHandle, 'Commport');
Message('port 1 is assigned');Message('port 1 is assigned');
-- try to close COM2, in case it was open for some reason. 0 = FALSE, -1 = TRUE
begin
OLE2.SET_PROPERTY(CommHandle, 'PortOpen', 0);
Message('port open');Message('port open');
exception
when others then
Message('port open');Message('port open'); -- if already open, ignore error
end;
-- Set device to 9600 baud, no parity, 8 data, and 1 stop bit.
OLE2.SET_PROPERTY(CommHandle, 'Settings', '9600,N,8,1');
Message('Port Values are Set');Message('Port Values are Set');
-- Open the port. 0 = FALSE, -1 = TRUE
OLE2.SET_PROPERTY(CommHandle, 'PortOpen', -1);
-- find out if the com port has opened successfully. 0 = FALSE, -1 = TRUE
--hold := OLE2.GET_num_PROPERTY(CommHandle, 'PortOpen');
Begin
OLE2.set_PROPERTY(CommHandle,'InBufferSize',1200);
string2:=Get_Ole_Var(CommHandle, 26);
string1:=var_to_Char(string2);
Exception
When Others Then
:block3.op:='Error In Reading';
Message('1'||SQlcode||sqlerrm);
Message('1'||SQlcode||sqlerrm);
End;
OLE2.SET_PROPERTY(CommHandle, 'InBufferCount', '0');
Message('Buffer Cleared');Message('Buffer Cleared');
Exception
When Others Then
Message(SQlcode||sqlerrm);Message(SQlcode||sqlerrm);
End;
Waiting for solution....