Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to copy the current record of a dataset Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Copy the current record of a dataset 25-Aug-02
Category
DB-General
Language
Delphi 2.x
Views
115
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Tomas Rutkauskas

Copy the current record of a dataset

Answer:

I found this routine which copies the current record of the currently selected 
record. This is useful e.g. to keep a temporary record for display in a form.
1   
2   {************************************************
3   // procedure AppendCurrent
4   //
5   // Will append an exact copy of the current
6   // record of the dataset that is passed into
7   // the procedure and will return the dataset
8   // in edit state with the record pointer on
9   // the currently appended record.
10  ************************************************}
11  
12  procedure AppendCurrent(Dataset: Tdataset);
13  var
14    aField: Variant;
15    i: Integer;
16  begin
17    // Create a variant Array
18    aField := VarArrayCreate(
19      [0, DataSet.Fieldcount - 1],
20      VarVariant);
21    // read values into the array
22    for i := 0 to (DataSet.Fieldcount - 1) do
23    begin
24      aField[i] := DataSet.fields[i].Value;
25    end;
26    DataSet.Append;
27    // Put array values into new the record
28    for i := 0 to (DataSet.Fieldcount - 1) do
29    begin
30      DataSet.fields[i].Value := aField[i];
31    end;
32  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC