随笔 - 730  文章 - 40 评论 - 17 阅读 - 67万

http://docwiki.embarcadero.com/RADStudio/XE6/en/TFDMemTable_Questions#Q:_How_can_I_copy_all_records_from_FDQuery_into_FDMemTable_and_edit_them_in_FDMemTable.3F

http://docwiki.embarcadero.com/RADStudio/XE6/en/Editing_Questions_%28FireDAC%29

http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic&frmfile=index.html

TFDMemTable is faster than TClientDataSet.

 FDQuery.OpenOrExecute

FDQuery Params

FDQuery->ParamByName("kl")->Value = edtkl->Text;  
FDQuery->Params->Items[0]->Value = cboyhmc->Text;  
FDQuery->Params->operator[](0)->Value = 0;

 

FDConnection1.SQL("INSERT INTO MyTable(Name, Age) VALUES(:name, :age)", [""AAA"", 11]);
FDConnection1.SQLScalar(""SELECT Age FROM MyTable WHERE Name = :x"", [""BBB""]);

 

FDMemTable1.CopyDataSet(DataSet1, [coStructure, coRestart, coAppend]);

copy all records from FDQuery into FDMemTable

FDQuery1.FetchOptions.Undirectional := False;
 
FDQuery1.Open;
FDQuery1.FetchAll;
FDMemTable1.Data := FDQuery1.Data;

remove dataset records without removing them from the database

A: You can work directly with internal dataset data storage. It is accessible through TFDDataSet.Table property. For example, to delete the row with index 3 do the following:

FDQuery1.Table.Rows[3].Free;
FDQuery1.UpdateCursorPos;
FDQuery1.Resync([]);

For example, to delete the current record, do the following:

FDQuery1.UpdateCursorPos;
FDQuery1.GetRow.Free;
FDQuery1.UpdateCursorPos;
FDQuery1.Resync([]);

Assigning TField.CustomConstraint does not work. What is wrong?

Q: Appending constraint via:

FDQuery.FieldByName('FIELD_NAME').CustomConstraint := 'FIELD_NAME > 1';
FDQuery.UpdateConstraints;
FDQuery.Table.Constraints.Check(FDQuery.GetRow(), rsModified, ctAtEditEnd);

Is not working and an exception is not raised.

A: That is OK (explanation will follow).

Q: But:

FDQuery.Constraints.Add.CustomConstraint := 'FIELD_NAME > 1';
FDQuery.UpdateConstraints;
FDQuery.Table.Constraints.Check(FDQuery.GetRow(), rsModified, ctAtEditEnd);

Is working! Why?

A: Also OK.

Q: What exactly do ctAtEditEnd and ctAtColumnChange mean?

A: These enums are specifying the event when FireDAC should check constraints:

  • ctAtEditEnd - the Post is called
  • ctAtColumnChange - a field value is modified

Now the explanation:

FDQuery.FieldByName('FIELD_NAME').CustomConstraint := 'FIELD_NAME > 1';

This adds a field-level constraint. They are checked at ctAtColumnChange event only.

FDQuery.Constraints.Add.CustomConstraint := 'FIELD_NAME > 1';

This adds a record-level constraint. They are checked at ctAtEditEnd event only.



FDQuery1.Command.CommandKind := skInsert; FDQuery1.ExecSQL;

FDQuery带参数Open

FDQuery1.Open('select * from tt where id=:id',[0]);

 Variant locvalues[1];

 locvalues[0] = Variant("01");

 FDQuery1->Open("select * from table where id=:id", locvalues, 0);

posted on   lypzxy  阅读(2916)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥
点击右上角即可分享
微信分享提示