Page 1 of 1

How to get data from Select sentence without fieldsName

Posted: Tue 06 Apr 2010 17:40
by arturo.r.monroy
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
:!: :!: :!: :!:

Posted: Wed 07 Apr 2010 00:59
by teunis
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.

Thank You

Posted: Wed 07 Apr 2010 15:18
by arturo.r.monroy
Thank You :wink: