Answer the question
In order to leave comments, you need to log in
Why is there a type mismatch error?
Can you please tell me why I get a type mismatch error when executing the following code?
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question