Firedac Query Field list not updated after Schema change

∥☆過路亽.° 提交于 2019-12-22 21:45:08

问题


I am creating a temp table in SQL and then adding a new field to it. It seems Firedac is caching the field list for this temp table.
The following code gives me "FDQuery5: Field 'Available' not found."

  FDQuery5.Connection := FDConnection1;
  FDConnection1.ExecSQL('Select StockNo into #Temp from Stock');
  FDQuery5.SQL.Text := 'Select * From #Temp';
  FDQuery5.open;
  FDConnection1.ExecSQL('Alter Table #Temp add Available Char(1)');
  FDQuery5.Close;
  FDQuery5.open;
  ShowMessage(FDQuery5.FieldByName('Available').AsString);

using XE5 with Firedac. I have tried Connection.RefreshMetadataCache and I have removed fiMeta from FetchOptions.Cache.

I can get Firedac to recognise the new field if I modify the SQL.Text. This is undesirable as my application will need modifying in quite a few places.


回答1:


The query remains prepared after you call FDQuery5.Close. That means, it caches also result set structure. To prepare the query replace FDQuery5.Close with FDQuery5.Disconnect.



来源:https://stackoverflow.com/questions/22317748/firedac-query-field-list-not-updated-after-schema-change

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!