AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi wie schreibe ich daten in eine paradox7 tabelle?
Thema durchsuchen
Ansicht
Themen-Optionen

wie schreibe ich daten in eine paradox7 tabelle?

Ein Thema von libFelix.so · begonnen am 9. Mär 2004 · letzter Beitrag vom 12. Mär 2004
Antwort Antwort
Seite 3 von 4     123 4      
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#21

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:16
Sql.Add('Insert into "' + StrTable + '" (Ort + ', ' + Datum + ', ' + Name + ', ' + Bahn1 + ', ' + Bahn1Ab + ', ' + Bahn1Drops + ', ' + Bahn2 + ', ' + Bahn2Ab + ', ' + Bahn2Drops + ', ' + Bahn3 + ', ' + Bahn3Ab + ', ' + Bahn3Drops + ', ' + Bahn4 + ', ' + Bahn4Ab + ', ' + Bahn4Drops + ', ' + GesDrops + ', ' + GesSL + ', ' + GesGT + ', ' + GesEL + ', ' + Gesamt + ') values (' + ComboBox2.Items.Strings[ComboBox2.ItemIndex] + ', ' + {DATUM} + ', ' + ComboBox1.Items.Strings[ComboBox1.ItemIndex] + ', ' + IntToStr(wupb1) + ', ' + IntToStr(wupb1ab) + ', ' + IntToStr(wupb1d) + ', ' + IntToStr(wupb2) + ', ' + IntToStr(wupb2ab) + ', ' + IntToStr(wupb2d) + ', ' + IntToStr(wupb3) + ', ' + IntToStr(wupb3ab) + ', ' + IntToStr(wupb3d) + ', ' + IntToStr(wupb4) + ', ' + IntToStr(wupb4ab) + ', ' + IntToStr(wupb4d) + ', ' + IntToStr(wupgesd) + ', ' + {GesSL} + ', ' + {GesGT} + ', ' + {GesEL} + ', ' + IntToStr(wupges) + ')'); mal NUR der insert befehl
  Mit Zitat antworten Zitat
Cuchulainn

Registriert seit: 26. Aug 2003
182 Beiträge
 
Delphi 5 Enterprise
 
#22

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:19
Versuch es mal damit:

Delphi-Quellcode:
Sql.Add('Insert into "' + StrTable + '" (Ort , Datum , Name, Bahn1, Bahn1Ab, Bahn1Drops, Bahn2,
'Bahn2Ab, Bahn2Drops, Bahn3, Bahn3Ab, Bahn3Drops, Bahn4, Bahn4Ab, Bahn4Drops, GesDrops, GesSL, GesGT, GesEL, Gesamt) values ('
+ ComboBox2.Items.Strings[ComboBox2.ItemIndex] +
', ' + DATUM + ', ' +
ComboBox1.Items.Strings[ComboBox1.ItemIndex] +
', ' + IntToStr(wupb1) + ', ' +
wupb1ab +
', ' + IntToStr(wupb1d) + ', ' + IntToStr(wupb2) + ', ' + wupb2ab + ', ' +
IntToStr(wupb2d) +
', ' + IntToStr(wupb3) + ', ' + wupb3ab + ', ' + IntToStr(wupb3d) + ', ' +
IntToStr(wupb4) +
', ' + wupb4ab + ', ' + IntToStr(wupb4d) + ', ' + IntToStr(wupgesd) + ', ' + GesSL
+
', ' + ', ' + GesGT + ', ' + ', ' + GesEL + ', ' + IntToStr(wupges) + ')');
  Mit Zitat antworten Zitat
Robert_G
(Gast)

n/a Beiträge
 
#23

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:21
Moin

Habt ihr beide schon mal was von Code-formatierung gehört?
Hättest du dein SQL-Statement besser formatiert (bei der Spaltenanzahl ein Muss!!!), hättest du zum Bleistift ein paar doppelte "," bemerkt.

Warum eigentlich das?
...'Ort ', ' + Datum + ', ' + Name + ', ... So ist es doch viel einfacher (und es funktioniert ) :
...'Ort, Datum, Name ... Ich habe mal schnell deinen Code etwas umformatiert.
Da ich ein paar Stellen geändert habe, kann es sein, dass er von dir korrigiert werden muss.
Delphi-Quellcode:
  With Query1 Do
  Begin
    SQL.Text :=
      'Insert INTO ' + StrTable + #10 +
      ' (Ort' + #10 +
      ' ,Datum' + #10 +
      ' ,Name' + #10 +
      ' ,Bahn1' + #10 +
      ' ,Bahn1Ab' + #10 +
      ' ,Bahn1Drops' + #10 +
      ' ,Bahn2' + #10 +
      ' ,Bahn2Ab' + #10 +
      ' ,Bahn2Drops' + #10 +
      ' ,Bahn3' + #10 +
      ' ,Bahn3Ab' + #10 +
      ' ,Bahn3Drops' + #10 +
      ' ,Bahn4' + #10 +
      ' ,Bahn4Ab' + #10 +
      ' ,Bahn4Drops' + #10 +
      ' ,GesDrops' + #10 +
      ' ,GesSL' + #10 +
      ' ,GesGT' + #10 +
      ' ,GesEL' + #10 +
      ' ,Gesamt)' + #10 +
      'VALUES' + #10 +
      ' (:i_Ort' + #10 +
      ' ,:i_Datum' + #10 +
      ' ,:i_Name' + #10 +
      ' ,:i_Bahn1' + #10 +
      ' ,:i_Bahn1Ab' + #10 +
      ' ,:i_Bahn1Drops' + #10 +
      ' ,:i_Bahn2' + #10 +
      ' ,:i_Bahn2Ab' + #10 +
      ' ,:i_Bahn2Drops' + #10 +
      ' ,:i_Bahn3' + #10 +
      ' ,:i_Bahn3Ab' + #10 +
      ' ,:i_Bahn3Drops' + #10 +
      ' ,:i_Bahn4' + #10 +
      ' ,:i_Bahn4Ab' + #10 +
      ' ,:i_Bahn4Drops' + #10 +
      ' ,:i_GesDrops' + #10 +
      ' ,:i_GesSL' + #10 +
      ' ,:i_GesGT' + #10 +
      ' ,:i_GesEL' + #10 +
      ' ,:i_Gesamt)';
    Prepared := True;
    With Params Do
    Begin
      ParamByName('i_Ort') .AsString := ORT;
      // Ich nahm an, dass DATUM in der Tabelle ein Datumsfeld ist
      ParamByName('i_DATUM') .AsDateTime := DATUM ;
      ParamByName('i_NAME') .AsString := NAME ;
      ParamByName('i_Bahn1') .AsInteger := wupb1;
      ParamByName('i_Bahn1Ab') .AsString := wupb1ab;
      ParamByName('i_Bahn1Drops').AsInteger := wupb1d;
      ParamByName('i_Bahn2') .AsInteger := wupb2;
      ParamByName('i_Bahn2Ab') .AsString := wupb2ab;
      ParamByName('i_Bahn2Drops').AsInteger := wupb2d;
      ParamByName('i_Bahn3') .AsInteger := wupb3;
      ParamByName('i_Bahn3Ab') .AsString := wupb3ab;
      ParamByName('i_Bahn3Drops').AsInteger := wupb3d;
      ParamByName('i_Bahn4') .AsInteger := wupb4;
      ParamByName('i_Bahn4Ab') .AsString := wupb4ab;
      ParamByName('i_Bahn4Drops').AsInteger := wupb4d;
      ParamByName('i_GesDrops') .AsInteger := wupgesd;
      ParamByName('i_GesSL') .AsString := GesSL;
      ParamByName('i_GesGT') .AsString := GesGT;
      ParamByName('i_GesEL') .AsString := GesEL;
      ParamByName('i_Gesamt') .AsInteger := wupges;
    End;
    ExecSQL;
  End;
Edit: Ein Haufen Tippfehler und Doppelpunkte in der Parameterzuweisung...
Edit 573 ( ) : Noch ein Doppelpunkt
  Mit Zitat antworten Zitat
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#24

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:25
Code:
[Fehler] Unit1.pas(150): ')' erwartet, aber Bezeichner 'ComboBox2' gefunden
sagt der mir nun... man is das kagge....


kann ich di das project mal schicken???
  Mit Zitat antworten Zitat
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#25

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:27
thx robert. ich probier es gleich mal aus und ja, bei dem feld datum soll das datum rein, das der user dan auswählt
  Mit Zitat antworten Zitat
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#26

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 12:37
also ich kann das programm nun endlich wieder starten, aber es trägt nix in die db ein.
wenn ich mir die mit dem tool dboberfläche anzeige, stehen da keine einträge.
  Mit Zitat antworten Zitat
Cuchulainn

Registriert seit: 26. Aug 2003
182 Beiträge
 
Delphi 5 Enterprise
 
#27

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 13:02
Wie sieht denn dein Quelltext jetzt aus?
  Mit Zitat antworten Zitat
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#28

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 13:06
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, DBTables, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    DBRadioGroup1: TDBRadioGroup;
    DBRadioGroup2: TDBRadioGroup;
    DBRadioGroup3: TDBRadioGroup;
    DBRadioGroup4: TDBRadioGroup;
    Query1: TQuery;
    DateTimePicker1: TDateTimePicker;
    Label12: TLabel;
    Label13: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Query1: TQuery;
  datum, wupb1, wupb2, wupb3, wupb4, wupb1d, wupb2d, wupb3d, wupb4d, wupb1ab, wupb2ab, wupb3ab, wupb4ab, wupgesd, wupsl, wupgt, wupel, wupges: integer;
  ort, name: string[50];

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

  //Einlesen der Variablen
  wupb1 := StrToInt(Edit2.Text);
  wupb2 := StrToInt(Edit3.Text);
  wupb3 := StrToInt(Edit4.Text);
  wupb4 := StrToInt(Edit5.Text);
  wupb1d := StrToInt (Edit7.Text);
  wupb2d := StrToInt (Edit8.Text);
  wupb3d := StrToInt (Edit9.Text);
  wupb4d := StrToInt (Edit10.Text);

  //Abzüge pro Bahn
  //Bahn1
  case DBRadioGroup1.ItemIndex of
    0 : wupb1 := wupb1 - 1;
    1 : wupb1 := wupb1 - 2;
    2 : wupb1 := wupb1 - 5;
  end;
  //Bahn2
  case DBRadioGroup2.ItemIndex of
    0 : wupb2 := wupb2 - 1;
    1 : wupb2 := wupb2 - 2;
    2 : wupb2 := wupb2 - 5;
  end;
  //Bahn3
  case DBRadioGroup3.ItemIndex of
    0 : wupb3 := wupb3 - 1;
    1 : wupb3 := wupb3 - 2;
    2 : wupb3 := wupb3 - 5;
  end;
  //Bahn4
  case DBRadioGroup4.ItemIndex of
    0 : wupb4 := wupb4 - 1;
    1 : wupb4 := wupb4 - 2;
    2 : wupb4 := wupb4 - 5;
  end;

  //Drops pro Bahn incl. Zuzüge
  wupb1 := (wupb1d * 2) + wupb1;
  wupb2 := (wupb2d * 2) + wupb2;
  wupb3 := (wupb3d * 2) + wupb3;
  wupb4 := (wupb4d * 2) + wupb4;

  //GesamtDrops
  wupgesd := wupb1d + wupb2d + wupb3d + wupb4d;

  //GesamtSchläge incl. Abzüge
  wupges := wupb1 + wupb2 + wupb3 + wupb4;

  //Ausgabe - Gesamt Drops
  Edit11.Text := IntToStr(wupgesd);

  //Ausgabe - Gesamt Schläge incl. Zu-/Abzüge
  Edit6.Text := IntToStr(wupges);

  name := ComboBox1.Items.Strings[ComboBox1.ItemIndex];
  ort := ComboBox2.Items.Strings[ComboBox2.ItemIndex];
  wupb1ab := 1;
  wupb2ab := 1;
  wupb3ab := 1;
  wupb4ab := 1;
  wupsl := 1;
  wupel := 1;
  wupgt := 1;
  datum := 1;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  f :textfile;

begin
  //In Datei schreiben
  AssignFile(f,'erg_wup.txt');
    {$i-}
      Append(f);
    {$i+}
    if IOResult <> 0 then halt;
      Writeln(f,ComboBox2.Items.Strings[ComboBox2.ItemIndex] + ',' + ComboBox1.Items.Strings[ComboBox1.ItemIndex] + ',' + Edit2.Text + ',' + Edit7.Text + ',' + Edit3.Text + ',' + Edit8.Text + ',' + Edit4.Text + ',' + Edit9.Text + ',' + Edit5.Text + ',' + Edit10.Text + ',' + Edit6.Text + ',' + Edit11.Text);
    CloseFile(f)

end;

procedure PEinlesen;
var
  StrTable: String;

begin
  StrTable := ExtractFilePath(ParamStr(0)) + 'db/db.db';
  // Datensätze mit Query einfügen
  With Query1 Do
  Begin
    SQL.Text :=
      'Insert INTO ' + StrTable + #10 +
      ' (Ort' + #10 +
      ' ,Datum' + #10 +
      ' ,Name' + #10 +
      ' ,Bahn1' + #10 +
      ' ,Bahn1Ab' + #10 +
      ' ,Bahn1Drops' + #10 +
      ' ,Bahn2' + #10 +
      ' ,Bahn2Ab' + #10 +
      ' ,Bahn2Drops' + #10 +
      ' ,Bahn3' + #10 +
      ' ,Bahn3Ab' + #10 +
      ' ,Bahn3Drops' + #10 +
      ' ,Bahn4' + #10 +
      ' ,Bahn4Ab' + #10 +
      ' ,Bahn4Drops' + #10 +
      ' ,GesDrops' + #10 +
      ' ,GesSL' + #10 +
      ' ,GesGT' + #10 +
      ' ,GesEL' + #10 +
      ' ,Gesamt)' + #10 +
      'VALUES' + #10 +
      ' (:i_Ort' + #10 +
      ' ,:i_Datum' + #10 +
      ' ,:i_Name' + #10 +
      ' ,:i_Bahn1' + #10 +
      ' ,:i_Bahn1Ab' + #10 +
      ' ,:i_Bahn1Drops' + #10 +
      ' ,:i_Bahn2' + #10 +
      ' ,:i_Bahn2Ab' + #10 +
      ' ,:i_Bahn2Drops' + #10 +
      ' ,:i_Bahn3' + #10 +
      ' ,:i_Bahn3Ab' + #10 +
      ' ,:i_Bahn3Drops' + #10 +
      ' ,:i_Bahn4' + #10 +
      ' ,:i_Bahn4Ab' + #10 +
      ' ,:i_Bahn4Drops' + #10 +
      ' ,:i_GesDrops' + #10 +
      ' ,:i_GesSL' + #10 +
      ' ,:i_GesGT' + #10 +
      ' ,:i_GesEL' + #10 +
      ' ,:i_Gesamt)';
    Prepared := True;
    With Params Do
    Begin
      ParamByName(':i_Ort') .AsString := ort;
      // Ich nahm an, dass DATUM in der Tabelle ein Datumsfeld ist
      ParamByName(':i_DATUM') .AsInteger := datum;
      ParamByName(':i_NAME') .AsString := name;
      ParamByName(':i_Bahn1') .AsInteger := wupb1;
      ParamByName(':i_Bahn1Ab') .AsInteger := wupb1ab;
      ParamByName(':i_Bahn1Drops').AsInteger := wupb1d;
      ParamByName(':i_Bahn2') .AsInteger := wupb2;
      ParamByName(':i_Bahn2Ab') .AsInteger := wupb2ab;
      ParamByName(':i_Bahn2Drops').AsInteger := wupb2d;
      ParamByName(':i_Bahn3') .AsInteger := wupb3;
      ParamByName(':i_Bahn3Ab') .AsInteger := wupb3ab;
      ParamByName(':i_Bahn3Drops').AsInteger := wupb3d;
      ParamByName(':i_Bahn4') .AsInteger := wupb4;
      ParamByName(':i_Bahn4Ab') .AsInteger := wupb4ab;
      ParamByName(':i_Bahn4Drops').AsInteger := wupb4d;
      ParamByName(':i_GesDrops') .AsInteger := wupgesd;
      ParamByName(':i_GesSL') .AsInteger := wupsl;
      ParamByName(':i_GesGT') .AsInteger := wupgt;
      ParamByName(':i_GesEL') .AsInteger := wupel;
      ParamByName(':i_Gesamt') .AsInteger := wupges;
    End;
    ExecSQL;
  End;
end;
end.
ist nun e erstmal der code....
sieht schiick aus, ist mit aber ehrlichgesagt zu lang.... aber dafür funzt es
  Mit Zitat antworten Zitat
Cuchulainn

Registriert seit: 26. Aug 2003
182 Beiträge
 
Delphi 5 Enterprise
 
#29

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 13:08
Du musst die Prozedur PEinlesen auch aufrufen. Sonst geschieht natürlich nichts
  Mit Zitat antworten Zitat
libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#30

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 13:23
oops wie peinlich

aber er gibt mir trotzdem ne fehlermeldung ca so:

ungültiges schlüsselwort
system-string: ?
zeilennummer: 1
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 4     123 4      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:23 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz