Home > Back-end >  Add three layers from the table data
Add three layers from the table data

Time:09-28

The server didn't do the code
Conn: TADOConnection;
The main table DS_main: TADODataSet;
From the table DS_item: TADODataSet;
DSP_main: TDataSetProvider; Associated with DS_main
DSmain: TDataSource;
DS_MAIN established master-slave relationship with DS_itme
Set up the nests
========================
The client
DCOM: TDCOMConnection;
Cds_main: the TClientDataSet;
Cds_mainorderID: TStringField;
Cds_mainorderDate: TStringField;
Cds_mainCustomer: TStringField;
Cds_mainDS_item: TDataSetField;


Add the code keystrokes
With the dm. Cds_main do
The begin
Append.
FieldByName (" orderid "). AsString:=e_djbh. Text;
FieldByName (" orderdate "). AsString:=formatdatetime (' - dd yyyy - mm, d_rq. Date);
FieldByName (" Customer "). AsString:=e_kh. Text;
end;
It is unclear how fine table data to add, please give us a hand to hand, thank you

CodePudding user response:

The main table, don't have to add table,
Add fine table must have the main table, through the foreign key relationships, details in the table to have a field id,
Delete the main table when certain details delete finished first,

CodePudding user response:

The database must be set up from the table and the relationship between the main table, set the foreign key to guarantee the accuracy of the data

CodePudding user response:

The main table AfterScroll event calls from the Open SQL=the select * from table from the table where the table the key fields of=key fields of the main table

CodePudding user response:

reference csn123 reply: 3/f
the main table AfterScroll event calls from the Open SQL=the select * from table from the table where table from the table key fields=the key fields of

Has been added, the database also did foreign key link

CodePudding user response:

1, define an event method, to open the SQL code from the table:
 procedure TShowOldChildFrm. SetKeyUp; 
Var SQL, ID, S: a string;
L: integer;
The begin
Eof then. If Not DBGrid1 DataSource. The DataSet.
The begin
ID:=DataModule1. ClientDataSet1. FieldByName (' ID '.) AsString;
DBGrid2. The DataSource:=DataModule1. DataSource2;
SQL:='select * From the name of the table where the old ID=' # 39 + ID + # 39 + 'order by "sort"';
DataModule1. ClientDataSet2. Active:=False;
DataModule1. ClientDataSet2. DataRequest (SQL);
DataModule1. ClientDataSet2. Active:=True;
end;

2, the main table DBGrid OnKeyUp and onm ouseUp event, add SetKeyUp;

In this way, can solve the master-slave table, according to

CodePudding user response:

Above, some code omitted for reference only,

CodePudding user response:

Dizzy, directly on the server to write master-slave separate save storage process, the client save time to launch the practice, the maintainability is strong, how to write a few lines of code.

CodePudding user response:

The client is going to save the data submitted to the server, by writing SQL server according to the business again use SQL one-time submit things,
The building Lord you should learn to write their own SQL, rather than a field to insert the data of a field the last Post,
Using the Post method is very pediatric writing, the sense that gives a person is a computer professional people to do,
If you want to learn the three layers, you can see the Demo Remobject experience under the three works,
Not like lyhoo163 write code on the client side of SQL as neither fish nor fowl of three layers,

CodePudding user response:

DataSnap master-slave table to realize, there are two ways:
Master-slave table (1) "nests", on the server side, through two on ADOQuery and DataSetProvider, corresponding to the master-slave two tables, and establish the master-slave relationship, the client of master-slave table through a pair of ClientDataSet, and through the master-slave DBGrid displayed, poor efficiency of this approach, a
Two (2) the client ClientDataset master-slave relationship between control, good efficiency, good flexibility, display and update the master-slave data is more convenient, this way, the client design, more flexible, not like a master-slave table "nests" if different customers to build 10 master-slave table, the server will be respectively set up 10 master-slave table related code (method), and client master-slave table, just set up on the client, the server only provides data,

The code above 5 floor, is only the client code,
  • Related