Thema: Delphi MySQL in MEMO anzeigen

Einzelnen Beitrag anzeigen

Benutzerbild von Leuselator
Leuselator

Registriert seit: 18. Mär 2003
Ort: Berlin
589 Beiträge
 
Delphi 8 Architect
 
#3

Re: MySQL in MEMO anzeigen

  Alt 10. Jan 2004, 02:10
Na gut:
Delphi-Quellcode:
const
  CLsFieldTypes: Array[0..35] of String = ('ftUnknown'    ,
                                           'ftString'     ,
                                           'ftSmallint'   ,
                                           'ftInteger'    ,
                                           'ftWord'       ,
                                           'ftBoolean'    ,
                                           'ftFloat'      ,
                                           'ftCurrency'   ,
                                           'ftBCD'        ,
                                           'ftDate'       ,
                                           'ftTime'       ,
                                           'ftDateTime'   ,
                                           'ftBytes'      ,
                                           'ftVarBytes'   ,
                                           'ftAutoInc'    ,
                                           'ftBlob'       ,
                                           'ftMemo'       ,
                                           'ftGraphic'    ,
                                           'ftFmtMemo'    ,
                                           'ftParadoxOle' ,
                                           'ftDBaseOle'   ,
                                           'ftTypedBinary',
                                           'ftCursor'     ,
                                           'ftFixedChar'  ,
                                           'ftWideString' ,
                                           'ftLargeint'   ,
                                           'ftADT'        ,
                                           'ftArray'      ,
                                           'ftReference'  ,
                                           'ftDataSet'    ,
                                           'ftOraBlob'    ,
                                           'ftOraClob'    ,
                                           'ftVariant'    ,
                                           'ftInterface'  ,
                                           'ftIDispatch'  ,
                                           'ftGuid');


procedure ShowInMemo(DieQuery : TDataSet, DasMemo : TMemo);
var i,
    j,
    AnzFields,
    AktLine : Integer;
begin
  DasMemo.Lines.Clear;
  if DieQuery.Active
    then DieQuery.First
    else DieQuery.Open;
  AnzFields := DieQuery.Fields.Count;
  DasMemo.Lines.Add(' Feld:'+chr(9));
  DasMemo.Lines.Add(' Typ:'+chr(9));
  DasMemo.Lines.Add('Länge:'+chr(9));
  DasMemo.Lines.Add('Zeile '+chr(9));
  for i := 0 to AnzFields-1 do begin // Kopf zusammenbauen
    DasMemo.Lines[0] := DasMemo.Lines[0]+DieQuery.Fields[i].Name;
    DasMemo.Lines[1] := DasMemo.Lines[1]+CLsFieldTypes[Ord(DieQuery.Fields[i].DataType)];
    DasMemo.Lines[2] := DasMemo.Lines[2]+IntToStr(DieQuery.Fields[i].DataSize);
    DasMemo.Lines[3] := DasMemo.Lines[3]+DieQuery.Fields[i].Name;
    if i < AnzFields-1
      then begin
        DasMemo.Lines[0] := DasMemo.Lines[0]+chr(9);
        DasMemo.Lines[1] := DasMemo.Lines[1]+chr(9);
        DasMemo.Lines[2] := DasMemo.Lines[2]+chr(9);
        DasMemo.Lines[3] := DasMemo.Lines[3]+chr(9);
      end;
  end;
  DasMemo.Lines.Add('');
  j := 1; // Zeilenzähler
  while not DieQuery.EOF do begin
    AktLine := DasMemo.Lines.Add(IntToStr(j)+chr(9));
    for i := 0 to AnzFields-1 do begin // Zeile zusammenbauen
      DasMemo.Lines[AktLine] :=DasMemo.Lines[AktLine]+DieQuery.Fields[i].DisplayText;
      if i < AnzFields-1
        then DasMemo.Lines[AktLine] := DasMemo.Lines[AktLine]+chr(9);
    end;
    inc(j); // Zeilenzähler erhöhen
    DieQuery.Next;
  end;
end;
Kann aber bei großen Ergebnismengen dauern!
Tim Leuschner
Programmierer = moderner Sysiphos: stets wenn er meint, den Stein seiner Dummheit auf den Berg des Wissens gewuchtet zu haben, erblickt er einen völlig neuen Aspekt und der Dummfels poltert mit Getöse zurück ins Tal der Unwissenheit...
  Mit Zitat antworten Zitat