A
A
animr2015-05-18 12:34:37
Delphi
animr, 2015-05-18 12:34:37

Why is there a type mismatch error?

Can you please tell me why I get a type mismatch error when executing the following code?
c7b97e8533d14d3eb3d30324292b702a.png
It is when the value of Integer.
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
varCounter : Integer;
varVariablePole : String;
varP_visible : Integer;
varP_date : TDate;
varP_article : String;
const
CRLF = #13#10;
begin
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Workbooks.Open(vargPathFileProduct);
dmContanierIcon.quProductAll.Close;
dmContanierIcon.quProductAll.SQL.Clear;
varCounter := 0;
while ExcelApp.ActiveSheet.UsedRange.Rows.Count do
begin
varCounter := varCounter + 1;
varVariablePole := ExcelApp.Range['I'+IntToStr(varCounter)];
if varVariablePole = '' then Break else
begin
varP_article := varVariablePole;
varVariablePole := ExcelApp.Range['A'+IntToStr(varCounter)];
varP_visible := StrToInt(varVariablePole);
varP_date := Date;
dmContanierIcon.quProductAll.SQL.Text := 'INSERT INTO dbt_ProductAll(p_visible, p_date, p_article)' + CRLF +
'VALUES(:_varP_visible, :_varP_date, :_varP_article)';
//Error adding this line
dmContanierIcon.quProductAll.ParamByName('_varP_visible').AsInteger := varP_visible;
//-----------------------------------
dmContanierIcon.quProductAll.ParamByName('_varP_date').AsDate := varP_date;
dmContanierIcon.quProductAll.ParamByName('_varP_article').AsString := varP_article ;
end;
dmContanierIcon.quProductAll.ExecSQL;
end;
ExcelApp.ActiveWorkbook.Close;
ExcelApp.Application.Quit;
end;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-05-18
@vilgeforce

The debugger didn't help?

K
kalapanga, 2015-05-18
@kalapanga

I will assume that in the dbt_ProductAll table, the p_visible field is not of an integer type, but some kind of boolean.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question