SDAC

TMSMetadata Class

A component for obtaining metainformation about database objects from the server.

For a list of all members of this type, see TMSMetadata members.

Unit

MSAccess

Syntax

TMSMetadata = class(TDAMetaData);

Remarks

The TMSMetaData component is used to obtain metainformation from the server about objects in the database, such as tables, table columns, stored procedures, etc in the form of a table. TMSMetaData publishes properties of TDAMetaData.

To get the information you are interested in, you should initially select the proper object type in the TMSMetadata.ObjectType property. After that you may open TMSMetadata and view the result like in usual dataset (in the DB-aware controls or from code). This dataset may be too big for viewing because information about all objects of the specified type is shown. To get the information only about objects you are interested in, you should specify appropriate filters in properties like DatabaseName, SchemaName, TableName, etc. To ascertain which properties are applicable to the selected object type, refer to the table given in the description of the ObjectType property.

Example

Here is a small example demonstrating obtaining information about default column values of a table.

procedure TForm.ButtonClick(Sender: TObject);
var
	FieldNameCol, FieldDefCol: TField;
  DefValue: string;
begin
  MSMetadata.ObjectType := otColumns;
  MSMetadata.DatabaseName := EditDatabaseName.Text;
  MSMetadata.TableName := EditTableName.Text;
  MSMetadata.Open;
  FieldNameCol := MSMetadata.FieldByName('COLUMN_NAME');
  FieldDefCol := MSMetadata.FieldByName('COLUMN_DEFAULT');

  Memo.Lines.Clear;
  if MSMetadata.RecordCount = 0 then
    Memo.Lines.Add('Specified object not found')
  else
    while not MSMetadata.Eof do begin
      if FieldDefCol.IsNull then
        DefValue := '> Not defined <'

      else
        DefValue := FieldDefCol.AsString;
      Memo.Lines.Add(Format('Field Name: %s;    Default Value: %s', [FieldNameCol.AsString, DefValue]));
      MSMetadata.Next;
    end;
end; 

Inheritance Hierarchy

TMemDataSet
   TDAMetaData
      TMSMetadata

See Also

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback