Home > Back-end >  Delphi string conversion issues
Delphi string conversion issues

Time:11-05

For I:=2 to ExcelRowCount do
The begin
If length (trim (Sheet) Cells [I, 1] Value)) & lt;=0 then break;
With ADOQuery1 do
The begin
The close;
SQL. The Clear;
SQL. Text:=(' Select * from ICSale where FHeadSelfI0461='" + strtointDef (Sheet. The Cells [I, 1). The Value, 0) + "' ");

Because of the character segment is of type int, import excel the first header row, unable to change the column attributes to numeric, before an error, the SQL. Add into SQL. Normal text, but you need to change the character type to int, use strtoint or strtointdef error
[error] Unit1. Pas (91) : Incompatible types: 'String' and 'Integer' excel is definitely an int type data

CodePudding user response:

Sheet. Cells [I, 1]. The Value is what type?

CodePudding user response:

StrtointDef (Sheet. Cells [I, 1). The Value of 0) here with the wrong function the function return Value is not a string type

CodePudding user response:

Use parameterized queries:
ADOQuery1. SQL. Text:='Select * from ICSale where FHeadSelfI0461=: FHeadSelfI0461';
ADOQuery1. The Parameters. ParamByName (' FHeadSelfI0461). Value:=Sheet. The Cells [I, 1). The Value;

CodePudding user response:

'Select * from ICSale where FHeadSelfI0461=' "+ strtointDef (Sheet. The Cells [I, 1). The Value of 0) +" '"' quotes for more,=not characters behind the
To the 'Select * from ICSale where FHeadSelfI0461=' '+ strtointDef (Sheet. The Cells [I, 1]. The Value, 0) +' ' '
  • Related