I am using the BDE and flat Tables.
I have two identical Tables, tblOne
and tblTwo
I am trying to copy the data from one table to the other. Not the entire DB, just one specific Record using this:
function Tdm.CopyRecord(var tblFrom,tblTo : TTable) : Boolean;
var
i : Integer;
begin
Result:=False;
try
tblTo.Insert;
for i:=1 to tblFrom.FieldCount-1 do
begin
if tblFrom.Fields[i].FieldName = tblTo.Fields[i].FieldName then
tblTo.Fields[i].Value:=tblFrom.Fields[i].Value;
end;
tblTo.Post;
Result:=True;
finally
end;
end;
if CopyRecord(tblOne,tblTwo) then...
Stepping through this all of the Values are "Null" for the From Table.
After the Post I get a blank record added to the tblTo
. Not surprising with all the Values a Null. :)
Where am I going wrong in copying the data? It is not making it to the Copy function.
I have been at this for several hours and cannot make it work. Probably something simple I am over-looking. I added the "var" parameter to see if that made any difference but it did not.
Oh, by the by, I am starting the loop from "1" not "0" as the first field in both files is an AutoInc
.