0
Good afternoon.
Work on a legacy system and need to put query information into a single memo object.
Code follows.
MyQuery.Close;
with MyQuery.SQL do
begin
clear;
add(' select TOP 8 nuentrada, dstpleitu, vlleitura, dshint, dtleitura, hhleitura ');
add(' from ssdentsinaisvitais inner join ssttplei on ssdentsinaisvitais.cdleitura = ssttplei.cdleitura ');
add(' where nuentrada = ' + lblnuentrada.Caption);
add(' order by dtleitura desc, hhleitura desc ');
end;
MyQuery.Open;
while MyQuery.Eof do
begin
mmdsexamefisico.Text := mmdsexamefisico.Text + MyQuery.DataSource.DataSet.FieldByName('dstpleitu').AsString + ': ';
mmdsexamefisico.Text := mmdsexamefisico.Text + MyQuery.DataSource.DataSet.FieldByName('vlleitura').AsString + #13#10;
end;
A syntax error occurs next to the word order.
Can detect the error?
To query
formed is the following:
SELECT TOP 8 nuentrada,
dstpleitu,
vlleitura,
dshint,
dtleitura,
hhleitura
FROM ssdentsinaisvitais
INNER JOIN ssttplei ON ssdentsinaisvitais.cdleitura = ssttplei.cdleitura
WHERE nuentrada = 350000701778
ORDER BY dtleitura DESC,
hhleitura DESC
Before the
Open
give aShowMessage(MyQuery.SQL.Text);
and inform what thequery
that was formed;– Sorack
Hello! select TOP 8 nuentrada, dstpleitu, vlleitura, dshint, dtleitura, hhleitura 
from ssdentsinaisvitais inner join ssttplei on ssdentsinaisvitais.cdleitura = ssttplei.cdleitura 
where nuentrada = 350000701778
order by dtleitura desc, hhleitura desc
– Lucas Augusto Coelho Lopes
It is explained then, the maximum size of the integer in SQL Server is 2147483647
– Sorack
You have to see then if you do not want to pass as string, if you want:
add(' where nuentrada = ''' + lblnuentrada.Caption + '''');
– Sorack
Glue the mistake for us there
– Sorack
Did you try to pass another value instead of 350000701778? for example 100.
– Ilyes
– Ilyes
Hello, everyone! I am using the Tquery object.
– Lucas Augusto Coelho Lopes