improvement for TDAParam.LoadFromFile (DBAccess.pas)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Eurocg
Posts: 14
Joined: Tue 15 Jul 2008 08:11
Location: Germany

improvement for TDAParam.LoadFromFile (DBAccess.pas)

Post by Eurocg » Fri 17 Oct 2008 10:52

Hello UniDac Team

Some application e.g. MS Word open files exclusive. If so i can not use TUniParams as Blob to save this file to DB.

Why? See your source (DBAccess):

Code: Select all

procedure TDAParam.LoadFromFile(const FileName: string; BlobType: TBlobType);
var
  Stream: TStream;
begin
  Stream := TFileStream.Create(FileName, fmOpenRead); // <<< Work not for exlusive open files
  try
    LoadFromStream(Stream, BlobType);
  finally
    Stream.Free;
  end;
end;
Please change this with next Update.

Code: Select all

Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone);

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 20 Oct 2008 14:46

We will not add this change to UniDAC because it will allow to write data to the file at the same time when UniDAC reads it.

Eurocg
Posts: 14
Joined: Tue 15 Jul 2008 08:11
Location: Germany

Post by Eurocg » Mon 20 Oct 2008 15:10

It's a pity. You not have to change the default function for it.

I mean you can overload the function or define a third parameter with default value, or declare a new funktion:

Code: Select all

type
  TOpenMode = (fmOpenRead, fmOpenWrite, ...)

// overlaod
procedure LoadFromFile(const FileName: string; BlobType: TBlobType); overload;
procedure LoadFromFile(const FileName: string; BlobType: TBlobType; OpenMode : TOpenMode); overload;

// default parameter
procedure LoadFromFile(const FileName: string; BlobType: TBlobType; OpenMode : TOpenMode default =fmOpenRead ); 

// or new function
procedure LoadFromFileShare(const FileName: string; BlobType: TBlobType); 
So I must make this change after each update of UNIDAC. That is also ok.
Thx

Post Reply