Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 18:12 
Hi, Delpher,

mit dem folgenden Code erzeuge ich eine DBTabelle. Diese Struktur ist allerdings bei einer anderen Tabelle schon vorhanden. Wie man sieht, gibt es keine ID, keine Indizes.

Kann ich die Struktur irgendwie übernehmen? For-Schleife?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
with TbSynctab do
    begin
      Active := False;
        DatabaseName := TbSchueler.DatabaseName;  //listbox11.items[listbox11.ItemIndex];
        TableName := 'Ssynctab'+ inttostr(j)+ '.dbf';
        TableType := ttDefault;  //  FoxPro, ttDBase;
        FieldDefs.Clear;
        FieldDefs.Add('Ident_Nr',   ftInteger,   0, False);
        FieldDefs.Add('Name',       ftString,   25, False);
        FieldDefs.Add('Vorname',    ftString,   25, False);
        FieldDefs.Add('Klasse',     ftString,    5, False);
        FieldDefs.Add('Fsprache1',  ftString,   15, False);
        FieldDefs.Add('Fsprache2',  ftString,   15, False);
        FieldDefs.Add('Wpk1name',   ftString,   50, False);
        FieldDefs.Add('Wpk2name',   ftString,   50, False);
        FieldDefs.Add('Wpk3name',   ftString,   50, False);
        FieldDefs.Add('Wpk4name',   ftString,   50, False);
        FieldDefs.Add('Geschlecht', ftString,    1, False);
        FieldDefs.Add('Gebdat',     ftDate,      0, False);
        FieldDefs.Add('Telefon',    ftString,   30, False);
      // IndexDefs.Clear;  IndexDefs.Add('PrimaryIndex', 'Klasse', NewIndexOptions);
      CreateTable;
      showmessage('Tabelle '+ TbSynctab.tablename+ ' ist erstellt');
    end;


Danke für Hilfe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 18:41 
Nimm ne TQuery und führ damit sowas aus wie das folgende:

Wenn die Zieltabelle noch nicht existiert:

ausblenden SQL-Anweisung
1:
2:
CREATE TABLE Zieltabelle
SELECT * FROM Quelltabelle WHERE 0


Whenn Du die Bedingung entsprechend formulierst, kannst Du auch beim Erzeugen gleich Daten reinkopieren lassen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 18:54 
okay, muss ich noch grabbeln, wegen Where ..

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 18:59 
Das WHERE 0 ist dafür da, damit er nur die Struktur selected.

Wie gesagt: Ansonsten mal schauen bzw. dem Hinweis bzgl. Befüllen mit Daten. Geht hier analog.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 19:22 
aha, danke!

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Moment, erzeugen und füllen gleichzeitig?

Wow, wie könnte das gehen? - Genau das brauche ich!

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 19:26 
Zähl mal bitte die Hinweise aus den beiden Topics kurz zusammen und nehm dann die Plausibelste Lösung ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 19:34 
also, ich käme dann auf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
create table TbHelp
select * from TbIst
where 0
insert into TbHelp
select * from TbIst


Det

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 19:47 
VIEL EINFACHER ;-)

ausblenden SQL-Anweisung
1:
2:
create table TbHelp
select * from TbIst

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 19:50 
ohne Insert, perfekt.

Meine Meinung: :D :D

Gruß, Det

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Na, ja, es gibt (noch) einen Fehler:

Allgemeiner SQL-Fehler, Syntax Error:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  chdir(label30.caption);

    TbSynctab2.DatabaseName := TbLk.DatabaseName;  // listbox11.items[listbox11.itemindex];
    TbSynctab2.TableName := 'Lsynctab'+ inttostr(j)+ '.dbf';
    TbSynctab2.TableType := ttDefault;  //ttFoxPro,  ttDBase;

    //****************************!!!
    QLk2.close;  QLk2.sql.clear;
        QLk2.sql.text := format('Create Table TbSynctab2 ' +
                                'Select * from "%s" ', [TbLk.tablename]);
    QLk2.ExecSql;
    //****************************!!!

  showmessage('Tabelle '+ TbSynctab2.tablename+ ' ist erstellt und mit Daten gefüllt!');


Welche Lösung gibt es hier?
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 22:14 
Welches DB-Frontend, Welches DB-Backend?

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 22:22 
Leider nur das ganz normale von D6Enter ... :(

// Hoffentlich keine bösen Kommentare

Ja, ich.

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 09.01.10 22:37 
Also BDE auf welche Datenbank im Hintergrund?

Weil bin jetzt von MySQL und Bindings ausgegangen, wo sowas nämlich Reibungslos geht.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.01.10 22:44 
Hast ja recht - dann muss ich wohl (wieder) 2 Befehle draus machen? [Siehe 2 Threads von mir]

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Upps, im Hintergrund liegt FoxPro!
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas