Page 1 of 1

Problem with SELECT statment, Please help!

Posted: Fri 08 Dec 2006 13:52
by Geraldm
Hi,

I am using MyDAC version 4.40.0.20 for Delphi 7.
MySQL version 4.1.14

I have a problem with the following code:

Code: Select all

Var Numlinks : Longint;
Begin
     MyConnection1.Connect;
     MyQuery1.SQL.Clear;
     MyQuery1.SQL.Add('SELECT COUNT(*) FROM `PLD_LINK`;');
     MyQuery1.Execute;
     repeat
         application.ProcessMessages;
     Until (executed) or (Cancel);
     If (Executeok) Then
     Begin
         Statusbar.Panels[0].Text := inttostr(MyQuery1.Params.count);
         NumLinks := strtoint(MyQuery1.Params[0].Asstring);  
     End;
     MyConnection1.Disconnect;
End;
executed is set to true once the MyQuery1.AfterExecute procedure is called.

The problem I have is that MyQuery1.Params.count = 0, but it should be at least 1 (ie, returning a row with the count) ???
Can you please let me know what I am doing wrong?

Thanks,
Gerald.

Posted: Fri 08 Dec 2006 15:19
by Geraldm
Sorry, my mistake ... I was using the wrong functions!!

I could have been using the following:

Code: Select all

Statusbar.Panels[0].Text := inttostr(MyQuery1.FieldCount);
NumLinks := strtoint(MyQuery1.Fields.Fields[0].AsString);