List Index out od Bounds(0)

Delphi

18/01/2007

Ola amigos, estou executando uma pesquisa sql para atualizar os valores de um DBchart mas esta aparecendo a seguinte mensagem de erro: List Index out of Bounds(0). Como resolver????

A Consulta SQL é esta :

QryProcRel.Active := false;
QryProcRel.SQL.Clear;
QryProcRel.SQL.Add
(´select TipoVenda, SUM(Total_Bruto_ped) , SUM(Desc_ped), SUM(Frete), SUM(Total_liq_ped), ´+
´SUM(Custo) from TabPedido where TabPedido.Situacao <> :sit and TabPedido.data >= :dtinicio and ´+
´TabPedido.data <= :dtfim and TabPedido.nr_nota_ped <> :nr_nota ´+´group by TipoVenda´);

QryProcRel.Params[0].DataType := ftString;
QryProcRel.Params[0].ParamType := ptInput;
QryProcRel.Params[0].Value := ´PR´;
QryProcRel.Params[1].DataType := ftDate;
QryProcRel.Params[1].ParamType := ptInput;
QryProcRel.Params[1].Value := DateTimePicker1.Date;
QryProcRel.Params[2].DataType := ftDate;
QryProcRel.Params[2].ParamType := ptInput;
QryProcRel.Params[2].Value := DateTimePicker2.Date;
QryProcRel.Params[3].DataType := ftstring;
QryProcRel.Params[3].ParamType := ptInput;
QryProcRel.Params[3].Value := ´Canc´;
QryProcRel.Active := true;


Rafaelfornazari

Rafaelfornazari

Curtidas 0

Respostas

Ruyoutor

Ruyoutor

18/01/2007

Boa tarde amigo!

Tenta ir dentro da propriedade sql e abrir as linhas dando enter
esse erro acontece quando vc tenta inserir informações em uma linha que ñ esta aberta usando o add eu acho q ñ era para acontecer, mas...

ao envés de vc usar sql.add use:

[/code]
Query.sql[0]:=´consulta´;

assim vc pode inserir direto na linha desejada esse código seu vc poderia dividir em três linhas por exemplo.

esse código que eu te passei funciona no ADOQuery mas ñ sei se no q vc esta usando funciona tenta ai qualquer coisa é só falar.

vlw!



GOSTEI 0
Davicarrano

Davicarrano

18/01/2007

este erro acontece quando você tenta acessar uma posição de vetor que nao existe... nesse caso provavelmente nao existe o parametro 3....


GOSTEI 0
Ruyoutor

Ruyoutor

18/01/2007

cara foi mau ai esqueci de fechar a tag do código sou muito desastrado
espero q vc entenda


GOSTEI 0
Aroldo Zanela

Aroldo Zanela

18/01/2007

Colega,


Adicione isso na propriedade SQL do objeto QryProcRel:
select TipoVenda,
       SUM(Total_Bruto_ped) ,
       SUM(Desc_ped),
       SUM(Frete),
       SUM(Total_liq_ped),
       SUM(Custo)
from
       TabPedido
where
       (TabPedido.Situacao <> :sit)
and
       (TabPedido.data between :dtinicio and :dtfim)
and
       (TabPedido.nr_nota_ped <> :nr_nota)
group by TipoVenda


No Delphi:

QryProcRel.Close;
QryProcRel.ParamByName(´sit´).AsString      := ´PR´;
QryProcRel.ParamByName(´dtinicio´).AsDate         := DateTimePicker1.Date;
QryProcRel.ParamByName(´dtfim´).AsDate         := DateTimePicker2.Date;
QryProcRel.ParamByName(´nr_nota´).AsString       := ´Canc´;
QryProcRel.Open;


Se for ADO, a sintaxe correta é:

QryProcRel.Parameters.ParamByName(´NomeParametro´).Value


GOSTEI 0
Emerson Nascimento

Emerson Nascimento

18/01/2007

o erro é exibido quando você abre a tabela?

tem que verificar se o erro é na tabela em si, ou em algum outro componente que a utiliza.

aparentemente o problema não está na lista de parâmetros (informe qual o componente que você está usando para acesso ao BD)

QryProcRel.Close;
QryProcRel.SQL.Text :=
  ´select TipoVenda, SUM(Total_Bruto_ped), SUM(Desc_ped), ´+
  ´  SUM(Frete), SUM(Total_liq_ped), SUM(Custo) ´+
  ´from TabPedido ´+
  ´where TabPedido.Situacao <> :sit ´+
  ´  and TabPedido.data between :dtinicio and :dtfim ´+
  ´  and TabPedido.nr_nota_ped <> :nr_nota ´+
  ´group by TipoVenda´;
QryProcRel.ParamByName(´sit´).AsString := ´PR´;
QryProcRel.ParamByName(´dtinicio´).AsDate := DateTimePicker1.Date;
QryProcRel.ParamByName(´dtfim´).AsDate := DateTimePicker2.Date;
QryProcRel.ParamByName(´nr_nota´).AsString := ´Canc´;
QryProcRel.Open;



GOSTEI 0
Rafaelfornazari

Rafaelfornazari

18/01/2007

Obrigado Amigos, com a ajuda de vc´s consegui solucionar este problema


GOSTEI 0
POSTAR