保存流 出现错误:[FireDAC][Phys]-329. Cannot generate update query. WHERE condition is empty

procedure SaveData(const Key: Integer; Stream: TMemoryStream);
  var db: TFDQuery;
begin
  db := TFDQuery.Create(nil);

  try
    db.Connection := Connection;
    db.SQL.Text   := 'SELECT [' + fnData + '] FROM [' + tbOutpatientCards + '] '+
      'WHERE [' + fnKey + '] = ' + IntToStr(Key);
    db.Open;

    if db.RecordCount > 0 then
    begin
      db.Edit;
      (db.FieldByName(fnData) as TBlobField).LoadFromStream(Stream);
      db.Post;
    end;
  finally
    db.Free;
  end;

end;

当执行上面的代码时,出现错误:[FireDAC][Phys]-329. Cannot generate update query. WHERE condition is empty

处理方法:在SELECT语句中增加主键字段

db.SQL.Text   := 'SELECT [' + fnKey + '] , [' + fnData + '] FROM [' + tbOutpatientCards + '] '+  'WHERE [' + fnKey + '] = ' + IntToStr(Key);

阅读更多
换一批

没有更多推荐了,返回首页