How to get data from Select sentence without fieldsName

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
arturo.r.monroy
Posts: 2
Joined: Tue 06 Apr 2010 17:19
Location: Mexico

How to get data from Select sentence without fieldsName

Post by arturo.r.monroy » Tue 06 Apr 2010 17:40

Hi i´ve a little problem, i'm developing a webServicesSQL using Delphi, my webServicesSQL is a dataModule and i use MyDAC.

I do know how to get the fields obtained from a SQL sentences without using the TMyQuery's fieldValues property. Anyone know???. Below i write a piece of code


Suposing a make a request 'SELECT * FROM calls ' and the Sentences responce 3 fields (id, call, timestamtp) and 3 rows, using TmyQuerys's fieldValue property is : MyQuery1.FieldValues['id'] .... BUT if i dont know the fields name ??? :!: :!: :!: :!: :!: :!:

function TWebServicesSQL.ejecutaQuery(SentSQL: UTF8String; Int: ShortInt): AnsiString;
beginSentSQL := URL_Decode(SentSQL);
if myConexion.Connected then
begin
myQuery.SQL.Text := SentSQL;
myQuery.Prepare;
if myQuery.IsQuery then
begin
myQuery.Execute;

result := ' ??';
end
else
...
end

REGARDS
ARTURO
:!: :!: :!: :!:

teunis
Posts: 48
Joined: Wed 01 Feb 2006 14:15
Location: Curacao

Post by teunis » Wed 07 Apr 2010 00:59

Use the propery Fields of the dataset.
Fields.Count number of fields in the dataset
Fields[n] the nth field in the dataset starting from 0

VAR astring: String;
astring:= Querry1.Fields[0].asString;
If the fieldtype is not BLOB then you get mostly a good result.

arturo.r.monroy
Posts: 2
Joined: Tue 06 Apr 2010 17:19
Location: Mexico

Thank You

Post by arturo.r.monroy » Wed 07 Apr 2010 15:18

Thank You :wink:

Post Reply