Announcement

Collapse
No announcement yet.

paradox-Tabelle auslesen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • paradox-Tabelle auslesen

    Hallo,
    Wie kann ich alle Elemente einer Spalte in einer Tabelle untereinander in ein Memofeld einlesen?
    mfg und vielen Dank
    Bastian

  • #2
    Hallo,

    das folgende Beispiel demonstriert, wie alle Werte der Spalte Capital der Tabelle COUNTRY.DB aus der Delphi-Beispieldatenbank DBDEMOS in einem TMemo dargestellt werden:
    <pre>
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, Db, DBTables;

    type
    TForm1 = class(TForm)
    Table1: TTable;
    Table1Name: TStringField;
    Table1Capital: TStringField;
    Table1Continent: TStringField;
    Table1Area: TFloatField;
    Table1Population: TFloatField;
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    private
    { Private-Deklarationen }
    public
    { Public-Deklarationen }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with Memo1.Lines do
    begin
    Table1.First;
    while not Table1.Eof do
    begin
    Add(Table1Capital.AsString);
    Table1.Next;
    end;
    end;
    end;

    end.
    </pre>
    Formular:
    <pre>
    object Form1: TForm1
    Left = 192
    Top = 107
    Width = 696
    Height = 480
    Caption = 'Form1'
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object Memo1: TMemo
    Left = 32
    Top = 64
    Width = 465
    Height = 233
    TabOrder = 0
    end
    object Button1: TButton
    Left = 72
    Top = 24
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
    end
    object Table1: TTable
    Active = True
    DatabaseName = 'DBDEMOS'
    TableName = 'country.db'
    Left = 32
    Top = 24
    object Table1Name: TStringField
    FieldName = 'Name'
    Size = 24
    end
    object Table1Capital: TStringField
    FieldName = 'Capital'
    Size = 24
    end
    object Table1Continent: TStringField
    CustomConstraint = 'X = '#39'South America'#39' OR X = '#39'North America'#39
    ConstraintErrorMessage = 'Country is not in the American Continent'
    DefaultExpression = #39'South America'#39
    FieldName = 'Continent'
    Size = 24
    end
    object Table1Area: TFloatField
    FieldName = 'Area'
    end
    object Table1Population: TFloatField
    FieldName = 'Population'
    end
    end
    end
    </pre&gt

    Comment

    Working...
    X