const
PHOTOTABLE = '
Tabellenname';
...
if (UpperCase(PhotoTB.FieldList.CommaText) = UpperCase(ImageSet.DefLst.CommaText))
and
(PhotoTB.FieldCount = ImageSet.DefLst.Count)
then
begin
// alte Tabelle umbenennen
PhotoTB.Close;
cat := CoCatalog.Create;
try
cat.Set_ActiveConnection(PhotoDB.ConnectionObject);
cat.Tables.Item[PHOTOTABLE].
Name := '
_images';
cat._Release;
except
Result := false;
Exit;
end;
// Neue Tabelle erstellen
SQL := '
CREATE TABLE ' + PHOTOTABLE + '
(';
if Length(_myLen) >= ImageSet.DefLst.Count
then
begin
for i := 0
to ImageSet.DefLst.Count - 1
do
if ImageSet.DefLst.Strings[i] <> '
Filename'
then
SQL :=
SQL + '
Field' + ImageSet.DefLst.Strings[i] + '
CHAR(' + IntToStr(_myLen[i]) + '
),';
SQL :=
SQL + '
FileName VARCHAR(' + IntToStr(_myLen[ImageSet.DefLst.Count-1]) + '
))';
PhotoCmd.CommandText :=
SQL;
PhotoCmd.Execute;
end
else begin
Result := false;
Exit;
end;
// Daten kopieren
myDS := TADODataSet.Create(
nil);
try
myDS.Connection := PhotoDB;
myDS.CommandText := '
SELECT * FROM _' + PHOTOTABLE;
myDS.Open;
myDS.First;
PhotoTB.CommandText := '
SELECT * FROM ' + PHOTOTABLE;
PhotoTB.Open;
PhotoTB.First;
while not myDS.Eof
do
begin
PhotoTB.Append;
for i := 0
to myDS.FieldCount - 1
do
begin
if UpperCase(myDS.Fields.Fields[i].FieldName) <> UpperCase('
FileName')
then
PhotoTB.FieldByName('
Field' + myDS.Fields.Fields[i].FieldName).Text := myDS.Fields.Fields[i].AsString
else PhotoTB.FieldByName(myDS.Fields.Fields[i].FieldName).Text := myDS.Fields.Fields[i].AsString;
end;
try
PhotoTB.Post;
myDS.Next;
except
PhotoTB.Cancel;
Result := false;
Exit;
end;
end;
myDS.Close;
myDS.Free;
PhotoTB.Close;
PhotoDB.Close;
except
myDS.Free;
Result := false;
Exit;
end;
// alte Tabelle löschen
PhotoCmd.CommandText := '
DROP TABLE _' + PHOTOTABLE;
PhotoCmd.Execute();
Application.ProcessMessages;
end;
if not PhotoDB.Connected
then
PhotoDB.Open;
if not PhotoTB.Active
then
PhotoTB.Open;
PhotoTB.Active := True;
Exit; <- an dieser Stelle bekomme ich die
Access Violation
...