Announcement

Collapse
No announcement yet.

Wie kann ich... (paradox7-Tabelle)

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

  • Wie kann ich... (paradox7-Tabelle)

    über ein Delphi-Proggy (Delphi5-Enterprise) Einträge in eine Paradox7-Tabelle tätigen ohne einen Query oder SGL zu verwenden. Hab ich da irgendwie "direkten" Zugriff drauf?
    z.B.
    with tabelle.markiertesFeld do ... ?!
    thnx

  • #2
    Hallo,

    selbstverständlich, denn hinter Paradox verbirgt sich <b>keine</b> SQL-Datenbank, so dass die BDE für Paradox über LOCAL SQL diese SQL-Fähigkeit <b>simulieren</b> muss.

    Wenn eine TTable-Komponente für die Paradox-Tabelle geöffnet wird und man auf TTable einen Doppelklick macht, erscheint der <b>Feld-Editor</b>, von dort aus steht über die rechte Maustaste (Felder hinzufügen) der Dialog für das Anlegen der persistenten TFields zur Verfügung, so dass man auf die Spalten direkt zugreifen kann. Mit der Delphi-Beispieldatenbank DBDEMOS sieht das zum Beispiel so aus:
    <pre>
    unit Unit1;

    interface

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

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

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Table1.Active := True;
    Table1.Edit;
    Table1Name.Value := 'Argentina (Neu)';
    Table1.Post;
    end;

    end.
    </pre>
    Das Formular dazu:
    <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 Button1: TButton
    Left = 72
    Top = 24
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
    end
    object DBGrid1: TDBGrid
    Left = 16
    Top = 80
    Width = 320
    Height = 120
    DataSource = DataSource1
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    end
    object Table1: TTable
    Active = True
    DatabaseName = 'DBDEMOS'
    TableName = 'country.db'
    Left = 16
    Top = 16
    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
    object DataSource1: TDataSource
    DataSet = Table1
    Left = 16
    Top = 48
    end
    end
    </pre>
    &#10

    Comment


    • #3
      Jo danke, Andreas,
      klappt wunderbar.
      Kannst du (oder jemand anderes) mir jetzt evtl nochmal helfen.
      Ich möchte auch eine Suchfunktion einbauen.
      Läuft das dann mit FindNearest? Hab da irgendwie keinen Ansatz,
      bin ja auch noch n Newbie...
      thnx, Bastia

      Comment


      • #4
        Hallo,

        im Allgemeinen ist die Methode <b>Locate</b> besser geeignet, da hier die VCL automatisch den schnellsten Weg sucht und der Entwickler sich gleich am Anfang nicht um alle Details kümmern muss. Unter <i>TBDEDataSet.Locate</i> ist ein Beispiel in der Delphi-Hilfe

        Comment

        Working...
        X