sveBerichte.FileName := cmbDownload.Text;
If not sveBerichte.execute then
Exit;
filepath := sveBerichte.Filename;
hexstring := '';
{I'll assume al this works as it should}
quyBerichte.close;
quyBerichte.SQL.Text := 'Select bericht from eberichte where nr = :nr';
quyBerichte.Params.ParambyName('nr').AsString := cmbdownload.text;
quyBerichte.open;
hexstring := quyBerichte.Fields[0].AsString;
quyBerichte.close;
HStream := TStringStream.Create(hexstring);
try
Stream := TFileStream.Create(filepath, fmCreate);
try
HStream.Seek(0, soFromBeginning); {Murphy-guard!}
{CByte is declared as String[2], isn't it?}
while HStream.Read(CByte[1], 2) > 0 do
Stream.Write(chr(StrToInt('0x' + CByte)));
finally
Stream.Free;
end;
finally
HStream.Free;
end;
end;