Delphi TFDUpdateSQL或TFDQuery在使用参数ftWideString执行sql后出错

Delphi TFDUpdateSQL或TFDQuery在使用参数ftWideString执行sql后出错,delphi,dataset,advantage-database-server,firedac,Delphi,Dataset,Advantage Database Server,Firedac,执行sql时,我得到一个错误: 数据库:Advantage(ADS) 更新sql的初始化: procedure TWarehouseLocationAgent.InitUpdateSQL; var oCmd: TFDCustomCommand; begin inherited; oCmd := self.UpdateSQL.Commands[arUpdate]; oCmd.CommandText.Add('UPDATE ARTIKELMAGAZIJN SET LOCATIE=

执行sql时,我得到一个错误:

数据库:Advantage(ADS)

更新sql的初始化:

procedure TWarehouseLocationAgent.InitUpdateSQL;
var
  oCmd: TFDCustomCommand;
begin
  inherited;
  oCmd := self.UpdateSQL.Commands[arUpdate];
  oCmd.CommandText.Add('UPDATE ARTIKELMAGAZIJN SET LOCATIE= :ALOCATION');
  oCmd.CommandText.Add('  WHERE ARTIKELNUMMER= :APARTID');
  oCmd.CommandText.Add('   AND MAGAZIJNNUMMER= :AWAREHOUSEID');

end;
更新数据程序:

procedure TWarehouseLocationAgent.Update(AWarehouseLocation: TWarehouseLocation);
var
  oCmd: TFDCustomCommand;
begin
  oCmd:= self.UpdateSQL.Commands[arUpdate];
  oCmd.ParamByName('ALOCATION').AsString := AWarehouseLocation.Location;
  oCmd.ParamByName('APARTID').AsInteger := AWarehouseLocation.PartID;
  oCmd.ParamByName('AWAREHOUSEID').AsInteger := AWarehouseLocation.WarehouseID;

  oCmd.Execute;  //--> get error
  if oCmd.RowsAffected <> 1 then
    raise ECFException.Create('Warehouselocation not found');
end;
程序TWarehouseLocationAgent.Update(AWarehouseLocation:TWarehouseLocation);
变量
oCmd:TFDCustomCommand;
开始
oCmd:=self.UpdateSQL.Commands[arUpdate];
oCmd.ParamByName('ALOCATION').AsString:=AWarehouseLocation.Location;
oCmd.ParamByName('APARTID').AsInteger:=AWarehouseLocation.PartID;
oCmd.ParamByName('AWAREHOUSEID').AsInteger:=AWarehouseLocation.WarehouseID;
oCmd.Execute;//-->出错
如果oCmd.RowsAffected 1,则
引发ECFEException.Create('Warehouselocation not found');
结束;
我发现param'ALOCATION'的数据类型为ftwidestring。 因此,我用params更改了InitUpdateSQL过程。 当我使用ftwidestring时,我会得到错误,如果我使用ftstring,则执行会运行

数据库中的字段“LOCATIE”是char(30)

奇怪的是,如果我必须使用ftString,数据集设置了ftWidestring

为什么我不能使用ftWideString

procedure TWarehouseLocationAgent.InitUpdateSQL;
var
  oCmd: TFDCustomCommand;
  oParam: TFDParam;
begin
  inherited;
  oCmd := self.UpdateSQL.Commands[arUpdate];
  oCmd.CommandText.Add('UPDATE ARTIKELMAGAZIJN SET LOCATIE= :ALOCATION');
  oCmd.CommandText.Add('  WHERE ARTIKELNUMMER= :APARTID');
  oCmd.CommandText.Add('   AND MAGAZIJNNUMMER= :AWAREHOUSEID');

  oCmd.Params.Clear;
  oParam:= oCmd.Params.Add;
  oParam.Name:='ALOCATION';
  //oParam.DataType := ftWideString;  <-- error with ftWideString
  oParam.DataType := ftString; // no error, why?

  oParam:= oCmd.Params.Add;
  oParam.Name:='APARTID';
  oParam.DataType := ftInteger;

  oParam:= oCmd.Params.Add;
  oParam.Name:='AWAREHOUSEID';
  oParam.DataType := ftInteger;
end;
过程TWarehouseLocationAgent.InitUpdateSQL;
变量
oCmd:TFDCustomCommand;
蛋白石:TFDParam;
开始
继承;
oCmd:=self.UpdateSQL.Commands[arUpdate];
Add('UPDATE ARTIKELMAGAZIJN SET LOCATIE=:ALOCATION');
Add('WHERE ARTIKELNUMMER=:APARTID');
Add('AND magazinNummer=:AWAREHOUSEID');
oCmd.Params.Clear;
oParam:=oCmd.Params.Add;
oParam.Name:=“位置”;

//oParam.DataType:=ftWideString;当你说“我发现param'ALOCATION'的数据类型是ftwidestring”时,你是怎么发现的?这就是FireDAC在IDE中设置的参数类型吗?@MartynA:Yes是由FireDAC设置的。当你说“我发现param'ALOCATION'的数据类型是ftwidestring”时,你是怎么发现的?这就是FireDAC在IDE中设置的参数类型吗?@MartynA:Yes是由FireDAC设置的。通过逐步调试找到。