Guide the data exported by Adodataset back to the original TABLE

xiaoxiao2021-03-06  107

We all know that AdodataSet can save data as local data files in XML or PDFG formats.

However, if you launch the data, don't make any modifications, apply the data with adodataset.loadfromfile next time.

The system will not send the data back to the original backup of Table, simply, I wrote a function, you can export a single table

Once again, it will go to the original table, but the condition is that your PK can't increase, if there is this situation, you can be in my code.

Take a little change, you can, it's not difficult, huh, huh.

Procedure ImportData (CONN: TADOCONNECTION; TABLENAME:

String; adodataset: tadodataset);

VAR

i: integer;

RDataSet: tadodataset;

Begin rDataSet: = tadodataset.create (nil);

RDataSet.Connection: = conn;

RDataSet.lockType: = LTBATCHOPTIMISTIC; RDataSet.comMandText: = Format ('SELECT TOP 1 * FROM% S', [TABLENAME]);

RDataSet.open; adodataset.first;

Try while not adodataset.eof do

Begin

RDataSet.Append;

For i: = 0

To adoDataset.fieldcount -1

DO

Begin rDataSet.fields [i] .value: = adodataset.fields [i] .value;

End; rdataset.post;

Adodataset.next;

END;

RDataSet.Updatebatch ();

Finally

RDataSet.Free;

END;

转载请注明原文地址:https://www.9cbs.com/read-103340.html

New Post(0)