Page 1 of 1

Fetch result from query - mydac - delphi

Posted: Tue 28 Oct 2008 01:57
by FROZENICE
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]

Posted: Tue 28 Oct 2008 16:39
by Podhorny
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;

Posted: Wed 29 Oct 2008 01:51
by FROZENICE
thanks bro ...

il check it out.
post results later..


br

Posted: Wed 29 Oct 2008 09:00
by FROZENICE
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