erro de tipo de dado imcompativel na expressao de criterio

Delphi

02/09/2011

Tenho um formulario de cadastro de pedido onde tenho uma outra tabela para cadastrar os produtos (utilizo relação de pai e filhos, um pedidos pode ter varios produtos) porem ao cadastrar ele mostra o erro: 'tipo de dado imcompativel na expressao de criterio', nao sei pq, porem dando break ou continue no erro ele salva do jeito que quero os dados que estou utilizando é o seguinte:
if StringGrid1.RowCount = 6 then exit; 
ADOTable1.Post; 
for i := 1 to StringGrid1.RowCount - 6 do 
begin 
Codultimoitem := strtoint(DBedit1.Text); 
ADOQuery1.Close; 
ADOQuery1.SQL.Clear; 
ADOQuery1.SQL.Add('insert into TABELAITEM (Codigo, Produto, Unidade, ValorUnitario, ValorUnitarioreal, Qtd, ValorTotal) values(:x, :a, :b, :c, :d, :e, :f)'); 
ADOQuery1.Parameters.ParamByName('x').Value := codultimoitem; 
ADOQuery1.Parameters.ParamByName('a').Value := StringGrid1.Cells[0,i]; 
ADOQuery1.Parameters.ParamByName('b').Value := StringGrid1.Cells[1,i]; 
ADOQuery1.Parameters.ParamByName('c').Value := StringGrid1.Cells[2,i]; 
ADOQuery1.Parameters.ParamByName('d').Value := StringGrid1.Cells[3,i]; 
ADOQuery1.Parameters.ParamByName('e').Value := StringGrid1.Cells[4,i]; 
ADOQuery1.Parameters.ParamByName('f').Value := StringGrid1.Cells[5,i]; 
ADOQuery1.ExecSQL; 
end;
Daniel

Daniel

Curtidas 0

Respostas

Joni Nunes

Joni Nunes

02/09/2011

Não seria pelo fato de o ValorTotal em sua tabela ser do tipo numérico e o grid.cell[5, i] retorna uma string, logo NUMBER recebendo STRING ?

Faça typecast para resolver, StrToInt e afins.


Abraço.
GOSTEI 0
POSTAR