TDataSet class consists TBDEDataSet (BDE assembly), TCustomADODataSet (ADO assembly), TIBCustomDataSet (InterBase assembly), TCustomSQLDataSet (dbExpress assembly) and TCustomClientDataSet subcategories.
Here DataSet class in the more important attributes (there may be trade-offs, until the real use of time to do the project during the supplement)
1.Active: determine whether the database has been opened;
2. Bof: determining a first record of the data set is active (in the following state and is true:. 1 Open a data set; 2 First method of accessing a data set; 3 Prior to use the method and the method has failed;. 4. a blank range or data set setRange method);
3. BookMark: setting a bookmark in the DataSet;
4. Buffers: providing an index to access the cache in the interior of the recording buffer;
5. CurrentRecord: recording index of the current record in the internal buffer of the buffer area;
6. DataSource: source data indicative of a data set other values is provided, the default value is nil;
7. Eof: determining whether the data set pointing to the last record (in the following cases is true: 1 opens an empty data set; Last call method 2; 3 method call to the next but the current record is the last record; 4. calling methods SetRange blank range or recording);
8. Found: a successful move to a different record;
9. IsUniDirectional: determining whether the data set is a subset of TCustomSQLDataSet;
10. Modifid: record whether the activity can be modified;
11. RecNo: Returns the number of records in a data set has been active;
12. RecordCount: number associated with the data set of records;
13. RecordSize: indicates the size of internal buffer is required (in the TDataSet, RecordSize 0);
14.State: setting state current mode of operation data sets (a data set is opened, the state becomes the dsbrowse dslnactive; edit mode (in dsEdit); insertion state (dsInsert); SetKey call or SetRange (dsSetKey); Posting or canceling (from the current state to dsBrowse); Closing data set (from the current state to dslnactive));
15.FieldValue: Method for providing access to the values of all fields in the active set of the recording data. (important)
Here are the more important TDataSet class method:
1.ActiveBuffer: returns a pointer to activity record buffer pointer. (Often with a bookmark with record activity record information in the cache of bookmark)
2.Append: add a new, empty record to the end of this data set. (important)
2.1 AppendRecord: Add a new record to the end of the empty data set and automatically post. E.g
Customer.AppendRecord([CustNoEdit.Text,CoNameEdit.Text, AddrEdit.Text, Null, Null, Null, Null, Null, Null, DiscountEdit.Text]);
3.FieldByName: access (only used to access a field that already exists, otherwise it will be reported EDatabaseError error) based on the name field. (important)
4.Post: which has been modified or written to the database records log [components directly to the ADO submit data to the database server]. (important)
TForm1.Button1Click Procedure (Sender: TObject); the begin SampleTable.Append; // Add a new record SampleTable.FieldValues [ 'ALPHANUMERIC']: = Edit1.text; // set two fields and assign SampleTable.FieldValues [ ' INTEGER ']: = StrToInt (Edit2.Text); SampleTable.Post; // commit record to a database or a log end;
5.Cancel: If there is no record of activity post, you can cancel the recording activity. But if the state is not recorded (dsEdit or dsInsert), the method is invalid. (important)
6.ClearFields: the value of all the fields of activity record cleared.
7.Close: Close a data set. (important)
8.Create: create a TDataSet object. (important)
9.Delete: Delete an activity record and move the pointer to the next record DataSet object. (important)
10.Destory: Destruction DataSet object (DataSet systematic usually automatic recovery). (important)
11.1 DisableControls: disable the use of data control displays data associated with a DataSet object.
11.2 EnableControls: and DisableControl just the opposite.
12.Edit: DataSet object enters edit mode. (important)
13.FindField: search field specifies the DataSet. (If it is not found, it returns nil) (important) for example:
with Table1 do begin FindField('CustNo').AsString := '1234'; Fields[0].AsString := '1234'; end;
14.1 FindFirst: Specifies whether the first record DataSet object, bool return type. (important)
14.2 FindLast: contrary to the FindFirst method. (important)
14.3 FindNext: determining whether the pointer is positioned next to a DataSet object data record, return bool type. (Important)
14.4 FindPior: just the opposite and FindNext methods. (Important)
than methods such as returns false, it indicates successful activation record is modified; returns true, the modification is successful.
15. First: move to the first record DataSet. The purpose of this method is invoked to make the first record in the DataSet to active. (important)
16. 1 BookMarkVid: assign a bookmark effectiveness.
16.2 CompareBookMarks: a virtual method to compare two bookmarks. (If BookMark1> BookMark2, the CompareBookMarks (BookMark1, BookMark2)> 0)
16.3 GetBookMark: assign records label data set activity. (Obtained from TBookMark)
16.4 SetBookMark: Activity Log Settings tab for the data set.
16.5 GotoBookMark: Locate the data set is marked activity record bookmark position. (important)
16.6 FreeBookMark: release the memory allocated to the specified label. (Important) For example:
procedure TForm1.CopyDataClick(Sender: TObject); var SavePlace: TBookmark; PrevValue: Variant; begin with MyData do begin { get a bookmark so that we can return to the same record } SavePlace := GetBookmark; //得到一个标签 try { move to prior record} FindPrior; { get the value } PrevValue := Fields[0].Value; {Move back to the bookmark this may not be the next record anymore if something else is changing the dataset asynchronously } GotoBookmark(SavePlace); { Set the value } Fields[0].Value := PrevValue; { Free the bookmark } finally FreeBookmark(SavePlace); end; end; end;
17. GetCurrentRecord: records returned in the cache. (E.g. returns false, it indicates that the buffer filling failure; as returns true, the cache is successful) (important)
18. A GetDetailDataSets: nested data sets will not be filled in a list of data sets.
19. GetFiledData: retrieve the value of the current field in the cache. (Bool return value, such as returns false, it means that values are not successfully extracted)
20.1 Insert: insert a new, empty records to the data set. (important)
20.2 InsertRecord: Insert a new, blank record and automatically post to the data set. (important)
21. IsEmpty: determining whether the data set is empty. (important)
22. IsLinkedTo: determining whether the data set via DataSource. (important)
23. Last: Move the pointer to the last record in the data set. (important)
24. MoveBy: recording the recording move from one activity to another. (important)
25. Next: move to the next record. (important)
procedure TForm1.Button1Click(Sender: TObject); var i: Integer; begin with ProgressBar1 do begin Min := 0; Max := Customers.RecordCount; Customers.First; for i := Min to Max do begin Position := i; Customers.Next; end; end; end;
26. Open: Open the data set. (important)