Error: 'Operation not applicable'

Hi Experts,
 I am getting an error: "Project abc.exe raised exception class EDBEngineError with message 'Operation not applicable.'. Process stopped. use Step or Run to continue." If I click 'OK' and Click run again, I get the error again but not anymore. Seems like I am getting the error twice but no more. I get this error after "showmessage('43');" and before "showmessage('44');"
Thanks for your help in advance


procedure TMainForm.SerialSheetShow(Sender: TObject);
begin
showmessage('40');
  DMForm.T_Port.Filtered := FALSE;
  with DMForm.Q_PortGrid do
  begin
  showmessage('41');
    if Active then Close;
    if (not DMForm.T_RTU.IsEmpty) and (not DMForm.T_Port.IsEmpty) then
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      Open;
      showmessage('44');
    end;
  end;
  showmessage('20');
  PortGridCellClick(nil);
end;

Open in new window

QurbanDurraniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rfwoolfCommented:
In this line:
'(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
shouldn't you have quotes or inverted commas, i.e.
'(port.P$RTUID = ' + QuotedStr(DMForm.T_RTURTUID.AsString) + ') AND ' +

You could try putting all your where conditions in one big set of brackets (see attached code below)

Other than that, I don't notice anything. for now...
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(' + 
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        ')' + 
        'ORDER BY port.PortNo');

Open in new window

0
QurbanDurraniAuthor Commented:
Just to add, This query has been working fine for a long time.
Thanks.
0
aikimarkCommented:
Depending on the database engine being used, I speculate that it is this part of your SQL:
'(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +

In most cases, you will need to compare text columns with a properly delimited value.  You should be able to use quotes or double apostrophe characters, or
QuotedString(DMForm.T_RTURTUID.AsString)
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

QurbanDurraniAuthor Commented:
I use BDE. As I stated in my question(probably not clearly), During the process of starting the application, The query errors twice, but the third time around, the query works just fine, not to mention that the query has been working fine for a long time. So it seems to me that the problem lies out side the query. My guess is that something is not being set or opened before the first two times the query is executed.
0
QurbanDurraniAuthor Commented:
I have tried both rtwoolf and aikimark suggestions, still getting the error.
0
diniludCommented:
procedure TMainForm.SerialSheetShow(Sender: TObject);
begin
showmessage('40');
  DMForm.T_Port.Filtered := FALSE;
  with DMForm.Q_PortGrid do
  begin
  showmessage('41');
    if Active then Close;
    if (not DMForm.T_RTU.IsEmpty) and (not DMForm.T_Port.IsEmpty) then
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      try
         Open;
      except
         on E: Exception do
        begin
           Showmessage(E.Message);
         end;
      end;
      showmessage('44');
    end;
  end;
  showmessage('20');
  PortGridCellClick(nil);
end;

Check what is the message?
 
0
QurbanDurraniAuthor Commented:
I tried dinilud suggestion, It only shows the old error message. No new error message is shown.
0
diniludCommented:
Try Like This
SQL.Add('SELECT port.PortID,port.PortNo,port.Type,'+
       'typelookup.Typeindex,typelookup.TypeString,'+
       'portlookup.PortIndex,portlookup.PortString  '+
       'FROM port  '+
       'INNER JOIN typelookup ON(typelookup.TypeIndex = port.Type) '+
       'INNER JOIN portlookup ON(portlookup.PortIndex = port.PortNo) '+
       'WHERE (port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND '+
       '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        ')' + 
        'ORDER BY port.PortNo');

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rfwoolfCommented:
Yeah have you tried without the line with P$RTUID ?
If there is no error you can at least know the problematic line and then focus on a solution...

as follows...
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
//        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      Open;
      showmessage('44');
    end;

Open in new window

0
QurbanDurraniAuthor Commented:
The problem is not with the query. It resides somewhere else. My guess is the query is being executed before some of the tables are initialized because the same query works after the application has finished starting up. Thanks to all for your help. I'll split the points up.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.