Geovana,

Tente assim :

with DmDadosSSP.ADOQryGeral do
                begin
                if active then Close;
                SQL.Clear;
                SQL.Add('SELECT COD_TEMPO, COD_EVENTO');
                SQL.Add('FROM SSP_REL_TEMPO_EVENTO');
                SQL.Add('WHERE COD_TEMPO=
'''+Trim(FrmAlterarPlanoAcao.sGridTemposCriados.Cells[0,i])+'''');
                SQL.Add('ORDER BY COD_TEMPO');
                InputBox('','',Sql.Text);
                Open;


                SQL.Clear;
                SQL.Add('SELECT COUNT(*) as QTD FROM SSP_REL_TEMPO_EVENTO');
                InputBox('','',Sql.Text);
               * cLinhasE:=FieldByName('QTD').AsInteger; // <<--  !!
ou 
               * cLinhasE:=Fields[0].AsInteger; // <<--  !!


[ ]´s
Moacir





Geovana Ventura escreveu:
> Pessoal,
>
>   Bom dia!
> Estou precisando atribuir o valor que representa o número de linhas de uma
> tabela para uma variável.
> Fiz este código abaixo, no entanto, está dando Access Violation quando passa
> por esta atribuição..
>
> with DmDadosSSP.ADOQryGeral do
>                 begin
>                 if active then Close;
>                 SQL.Clear;
>                 SQL.Add('SELECT COD_TEMPO, COD_EVENTO');
>                 SQL.Add('FROM SSP_REL_TEMPO_EVENTO');
>                 SQL.Add('WHERE COD_TEMPO=
> '''+Trim(FrmAlterarPlanoAcao.sGridTemposCriados.Cells[0,i])+'''');
>                 SQL.Add('ORDER BY COD_TEMPO');
>                 InputBox('','',Sql.Text);
>                 Open;
>
>
>                 SQL.Clear;
>                 SQL.Add('SELECT COUNT(*) FROM SSP_REL_TEMPO_EVENTO');
>                 InputBox('','',Sql.Text);
>                * cLinhasE:=FieldByName('COUNT(*)').AsInteger; // ( aqui dá o
> erro Acess Violation)*
>
> Vcs tem alguma dica de como posso conseguir fazer isso?
> Obrigada!!
>   

Responder a