Fetch result from query - mydac - delphi

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FROZENICE
Posts: 6
Joined: Thu 16 Oct 2008 03:25
Contact:

Fetch result from query - mydac - delphi

Post by FROZENICE » Tue 28 Oct 2008 01:57

hi.. i have this code

i got
myconnection
myquery
mydatasource
and dbgrid

Code: Select all

 try
    myQuery1.SQL.Text := 'SELECT MIN(ticketnum) FROM onque WHERE status="waiting" ';
     myQuery1.Execute ;
  finally
   // myQuery.Close ;
   
  end;
when i execute this.. result will display on my dbgrid.
what i want to is to display it on a caption or on the dbtext :)
or anaywhere else but not on the dbgrid

im sorry im not really expert into this..

example in php

Code: Select all

$query = " select * from table where id='2' ";
$result = mysql_query($result) or die ('error ');
if ($result) {
  $row = mysql_fetch_assoc($result);
  $name = $row['name'];
  $id = $row['id'];

  echo "id: $id name: $name";
}
if this is in php .. how will i do it in delphi using mydac ..
i just want to fetch the data from my query and display it. like puting it into label caption..


thanks in advance


br[/code][/quote]

Podhorny
Posts: 1
Joined: Wed 22 Oct 2008 09:15
Location: Czech Republic

Post by Podhorny » Tue 28 Oct 2008 16:39

I am using something like this:

var ii:integer;
s1:string;
i1:integer;

if MyQuery.RecordCount>0 then // do we have any results?
begin
for ii:=1 to MyQuery.RecordCount do // for all results do
begin
MyQuery.Recno:=ii;
s1:=MyQuery.Fields[0].AsString; // first value -> index 0!
i1:=MyQuery.Fields[1].AsInteger;
...
end;
end;

FROZENICE
Posts: 6
Joined: Thu 16 Oct 2008 03:25
Contact:

Post by FROZENICE » Wed 29 Oct 2008 01:51

thanks bro ...

il check it out.
post results later..


br

FROZENICE
Posts: 6
Joined: Thu 16 Oct 2008 03:25
Contact:

Post by FROZENICE » Wed 29 Oct 2008 09:00

ahmm..

i did manage to do what i wanted to..
but... in other way .. i did use a webbrowser then integrate a php code
parse the result convert to string :)


br
frozenice

Post Reply