Autor Beitrag
delphimike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Mo 04.04.05 14:17 
Wie kann ich ein neues Feld einer Datenbank zur Laufzeit erzeugen?

Mit Fielddefs.add (...) klappt es nur wenn ich danach per Createtable die ganze Tabelle neu erzeuge. Sinn des ganzen ist eine automatische Updateroutine, die die Datenbankstruktur ergänzen soll.
OlliWausD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Di 05.04.05 09:17 
ausblenden Quelltext
1:
Alter Table ABCTabelle Add Feldname Integer;					


mfg

Olli W

_________________
Take it easy
delphimike Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 05.04.05 10:42 
danke, das klingt aber sehr nach Paradox Programmiersprache, in Delphi wird das so nicht klappen

Gruß Mike
OlliWausD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Di 05.04.05 10:55 
du musst den Befehl in eine Query packen und anschließend ausführen. Läuft alles auf DB-Ebene ab.

mfg

Olli W

_________________
Take it easy
OlliWausD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Di 05.04.05 10:58 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.button1click(sender:TObject);
var Query:TQuery;
begin
  Query := TQuery.create(nil);
  Query.databasename = 'X';
  Query.sql.text := 'ALTER TABLE AbcTabelle ADD FeldnameDerNeuenSpalte Integer';
  Query.execsql;
  Query.free;
end;


mfg

Olli W

_________________
Take it easy
delphimike Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Di 05.04.05 14:44 
Danke, scheint auf den ersten Blick ein komplexer Umweg zu sein aber funktioniert

Habe es mit integer und boolean probiert. Wenn ich jetzt noch wüßte wie ein String mit 20 zeichen definiert wird, wäre ich glücklich (STRING 20 mag das Programm leider nicht)

Gruß Mike
OlliWausD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Di 05.04.05 15:58 
entweder:
ausblenden Quelltext
1:
ALTER TABLE AbcTabelle ADD FeldnameDerNeuenSpalte Char(20)					

oder
ausblenden Quelltext
1:
ALTER TABLE AbcTabelle ADD FeldnameDerNeuenSpalte VarChar(20)					


Ich nehme mal an, den Unterschied kennst du :P

mfg

Olli W

Edit: Ps.: Wie schon gesagt, du arbeitest hier nicht auf der Objekt-Schiene sondern auf Datenbank-Ebene (SQL) !
Hier mal n Schöner Link für SQL-Programmierung: www.little-idiot.de/mysql/mysql.html#toc28

_________________
Take it easy