Autor Beitrag
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 11.07.09 10:01 
Habe jetzt weiter eingegrenzt:

For i := 0 to 5 do // slFieldNames.Count - 1 do

wenn ich also slFieldnames.count-1 durch die Zahl 5 ersetze (weil es 6 Felder sind), dann tritt keine Fehlermeldung mehr auf, aber es werden auch keine Daten geschrieben.

Seltsam, seltsam,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Sa 11.07.09 10:03 
Wie hoch ist den slFieldNames.Count? Wird vielleicht ein leerer Eintrag erzeugt?

Merke: In der Softwareentwicklung ist nichts 'seltsam', sondern immer erklärbar.

_________________
Na denn, dann. Bis dann, denn.
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 11.07.09 10:15 
So, nun klappt es:

ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
Procedure TForm1.CopyTables (aTblName : String; aSrc, aDst : TTable; aFieldnames : String);
Var  srcFields, dstFields : Array Of TField;
     i                    : Smallint;
     slFieldNames         : TStringList;
Begin
  aSrc.Close;
    aSrc.TableName := concat(home, '\', aTblName);
  aSrc.active := true;
  slFieldNames := CreateStringListFromCommaString(aFieldNames);
  Try
    setLength(srcFields, slFieldNames.Count);
    setLength(dstFields, slFieldNames.Count);
    For i := 0 to slFieldNames.Count - 1 do
    begin
      srcFields[i] := aSrc.FieldByname(slFieldnames[i]);
      dstFields[i] := aDst.FieldByname(slFieldnames[i]);
    End;
    aSrc.First;
    while not aSrc.Eof do
    Begin
      aDst.Append;
      For i := 0 to slFieldNames.Count - 1 do
        DstFields[i].Value := SrcFields[i].Value;
      aDst.Post;
      aSrc.Next;
    End;
    showmessage('merge '+ aSrc.TableName + ' ok');
  Finally
    slFieldNames.Free;
  End;
End;


Danke für deine Mühe, "alzi"
Gruß aus Lübeck von "Deti"

_________________
ut vires desint, tamen est laudanda voluntas
kkausp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77
Erhaltene Danke: 1

W2K, WIN XP, WIN XPe; WIN7
(D1;D2;D5;) D6 Ent.; D2009 Ent.
BeitragVerfasst: Sa 11.07.09 10:30 
Hallo,

Es gibt für die BDE die Delphi Komponente TBATCHMOVE, welche auch das kopieren von Datensätzen ermöglicht.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Sa 11.07.09 14:12 
Nur sollte man die BDE in die Tonne treten. Leider, denn daran hatte ich zwischendurch auch mal gedacht.

_________________
Na denn, dann. Bis dann, denn.