 |
|
EnterpriseDBDAC
Example: ParamCount, DataType, StrToIntDef, AsXXX | | Previous Next |
This example fills in the parameters of a query from the entries of a list box.
var
I: Integer;
ListItem: String;
begin
for I := 0 to EDBQuery1.ParamCount - 1 do
begin
ListItem := ListBox1.Items[I];
case EDBQuery1.Params[I].DataType of
ftString:
EDBQuery1.Params[I].AsString := ListItem;
ftSmallInt:
EDBQuery1.Params[I].AsSmallInt := StrToIntDef(ListItem,0);
ftInteger:
EDBQuery1.Params[I].AsInteger := StrToIntDef(ListItem,0);
ftWord:
EDBQuery1.Params[I].AsWord := StrToIntDef(ListItem,0);
ftBoolean:
begin
if ListItem = 'True' then
EDBQuery1.Params[I].AsBoolean := True else
EDBQuery1.Params[I].AsBoolean := False;
end;
ftFloat:
EDBQuery1.Params[I].AsFloat := StrToFloat(ListItem);
ftCurrency:
EDBQuery1.Params[I].AsCurrency := StrToFloat(ListItem);
ftBCD:
EDBQuery1.Params[I].AsBCD := StrToCurr(ListItem);
ftDate:
EDBQuery1.Params[I].AsDate := StrToDate(ListItem);
ftTime:
EDBQuery1.Params[I].AsTime := StrToTime(ListItem);
ftDateTime:
EDBQuery1.Params[I].AsDateTime := StrToDateTime(ListItem);
end;
end;
end;
|