On the programming design of memory control Tdxmemdata

Source: Internet
Author: User

The Tdxmemdata control can store the dataset database in memory and display it on Tdxdbgrid, and through DXMDT1. Fieldbyname (' field '). Value gets the current cursor position. Iterates through the values in the entire dataset through the while. So you can manipulate the data in memory and then commit to the database with the SQL statement, usually a record has been modified operation, the internal operation can be implemented: Add or remove changes to the button is only to manipulate the data in memory, when the button is actually saved to submit to the database. Facilitate the processing of data.
Tdxmemdata Application Sample code:
Unit Unit1;

Interface

Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, DB, ADODB, DXEXEDTR, DXDBTLCL, Dxgrclms, Dxdbctrl,
Dxdbgrid, DXTL, Dxcntner, Dxmdaset, Grids, Dbgrids;

Type
TForm1 = Class (Tform)
Qry1:tadoquery;
Con1:tadoconnection;
Mmo1:tmemo;
Btn1:tbutton;
Dxmdt1:tdxmemdata;
Dxdbgrd1:tdxdbgrid;
Ds1:tdatasource;
Intgrflddxmdt1orderid:tintegerfield;
Intgrflddxmdt1custid:tintegerfield;
Intgrflddxmdt1empid:tintegerfield;
Dtflddxmdt1orderdate:tdatefield;
Strngflddxmdt1shipaddress:tstringfield;
Dxdbgrdclmndxdbgrd1recid:tdxdbgridcolumn;
Dxdbgrdmskclmndxdbgrd1orderid:tdxdbgridmaskcolumn;
Dxdbgrdmskclmndxdbgrd1custid:tdxdbgridmaskcolumn;
Dxdbgrdmskclmndxdbgrd1empid:tdxdbgridmaskcolumn;
Dxdbgrdtclmndxdbgrd1orderdate:tdxdbgriddatecolumn;
Dxdbgrdmskclmndxdbgrd1shipaddress:tdxdbgridmaskcolumn;
Btn2:tbutton;
Dbgrd1:tdbgrid;
Btn3:tbutton;
Procedure Btn1click (Sender:tobject);
Procedure Btn2click (Sender:tobject);
Procedure Btn3click (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End

Var
Form1:tform1;

Implementation
{$R *.DFM}

Procedure Tform1.btn1click (Sender:tobject);
Var
I:integer;
Begin
I:=1;
Qry1. Connection:=con1;
Qry1. Sql. Clear;
Qry1. Sql. Add (' Select Top ' orderid,custid,empid,orderdate,shipaddress from TSQLFundamentals2008.sales.Orders ');
Qry1. Open;
Qry1. First;
While not qry1. Eof do
Begin
Dxmdt1. Append; Add a read value from the data to memory
Dxmdt1. Fieldbyname (' RecId '). Asinteger:= (i+1);
Dxmdt1. Fieldbyname (' OrderID '). Asinteger:=strtoint (Qry1. Fieldbyname (' OrderID '). asstring);
Dxmdt1. Fieldbyname (' CustID '). Asinteger:=strtoint (Qry1. Fieldbyname (' CustID '). asstring);
Dxmdt1. Fieldbyname (' Empid '). Asinteger:=strtoint (Qry1. Fieldbyname (' Empid '). asstring);
Dxmdt1. Fieldbyname (' OrderDate '). Asdatetime:= strtodate (qry1. Fieldbyname (' OrderDate '). asstring);
Dxmdt1. Fieldbyname (' shipaddress '). Asstring:=qry1. Fieldbyname (' shipaddress '). asstring;
Mmo1. Lines.add (Qry1. Fieldbyname (' OrderDate '). asstring);
Qry1. Next;
Inc (I);
End
Qry1. Close;
End

Procedure Tform1.btn2click (Sender:tobject);
Begin
Dxmdt1. First;
While not dxmdt1. Eof do
Begin
if (dxmdt1. Fieldbyname (' OrderID '). asinteger=10249) or (dxmdt1. Fieldbyname (' OrderID '). ASINTEGER=10250) Then
Begin
Dxmdt1.      Edit; Need to be set to edit mode first
Dxmdt1. Fieldbyname (' shipaddress '). asstring:= ' Zheng Zhou ';
End
Dxmdt1. Next;
End
Dxmdt1. Edit;
Dxmdt1. Post;
Dxmdt1. First;
End
Procedure Tform1.btn3click (Sender:tobject);
Begin

End

End.

On the programming design of memory control Tdxmemdata

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.