Board index » delphi » Compact Access 2000 database with security

Compact Access 2000 database with security

Greetings, I am getting error when calling CompactDatabase.
You do not have the necessary permissions to use the Path+'xxx.mdb' ...have
admin set up permission for you.
The path and database is correct.
Using D5, Access 2000 via ODBC

varDBEngine call to set up authority somehow?
I am setting upUser Name and Password in tDatabase compoment and I
understand that varDBEngine is outside of that.

code below:  (thanks)

function PackAccessDB(db:TDataBase): boolean;
var varDBEngine: variant;
    strDBPathName,
    strTempPathName: string;
begin
  result := true;
  try
    strDBPathName := DataLocation;  \\correct
    strTempPathName := DataDirectory + '\temp.mdb'; \\correct
    varDBEngine := CreateOleObject('DAO.DBEngine.36');
    try
      db.Connected := false;
      varDBEngine.CompactDatabase(strDBPathName, strTempPathName);  /error
occurs here
      DeleteFile(strDBPathName);
      RenameFile(strTempPathName, strDBPathName);
    except
      result := false;
    end;
  finally
    DB.Params.Free;
    varDBEngine := Unassigned;
    db.Connected := true;
  end;
end;

 

Re:Compact Access 2000 database with security


I do have exclusive verified at his point.  That is not the problem.
I think it has to do with my security filein Access(mdw).

Quote
"Ann Weaver" <annwea...@nospamlllow.com> wrote in message

news:3ab12eac$1_2@dnews...
Quote
> When you run compact it requires that everyone be out of the database. Is
> there a way to tell if anyone is using the database? Or that a compact is
in
> progress when you try and run the application?

> leapin <wa...@resa.net> wrote in message news:3aae8c8d$1_2@dnews...
> > Greetings, I am getting error when calling CompactDatabase.
> > You do not have the necessary permissions to use the Path+'xxx.mdb'
> ...have
> > admin set up permission for you.
> > The path and database is correct.
> > Using D5, Access 2000 via ODBC

> > varDBEngine call to set up authority somehow?
> > I am setting upUser Name and Password in tDatabase compoment and I
> > understand that varDBEngine is outside of that.

> > code below:  (thanks)

> > function PackAccessDB(db:TDataBase): boolean;
> > var varDBEngine: variant;
> >     strDBPathName,
> >     strTempPathName: string;
> > begin
> >   result := true;
> >   try
> >     strDBPathName := DataLocation;  \\correct
> >     strTempPathName := DataDirectory + '\temp.mdb'; \\correct
> >     varDBEngine := CreateOleObject('DAO.DBEngine.36');
> >     try
> >       db.Connected := false;
> >       varDBEngine.CompactDatabase(strDBPathName, strTempPathName);
/error
> > occurs here
> >       DeleteFile(strDBPathName);
> >       RenameFile(strTempPathName, strDBPathName);
> >     except
> >       result := false;
> >     end;
> >   finally
> >     DB.Params.Free;
> >     varDBEngine := Unassigned;
> >     db.Connected := true;
> >   end;
> > end;

Re:Compact Access 2000 database with security


My apologies for the confusion. I am not able to answer your question (I
wish I could) but am getting ready to implement a compact database option
for my application and was curious about how to tell if anyone was using the
database and how to set exclusive access.  Sorry, I should have posted a new
message instead of a response to yours.

Quote
leapin <wa...@resa.net> wrote in message news:3ab27d03$1_2@dnews...
> I do have exclusive verified at his point.  That is not the problem.
> I think it has to do with my security filein Access(mdw).

> "Ann Weaver" <annwea...@nospamlllow.com> wrote in message
> news:3ab12eac$1_2@dnews...
> > When you run compact it requires that everyone be out of the database.
Is
> > there a way to tell if anyone is using the database? Or that a compact
is
> in
> > progress when you try and run the application?

> > leapin <wa...@resa.net> wrote in message news:3aae8c8d$1_2@dnews...
> > > Greetings, I am getting error when calling CompactDatabase.
> > > You do not have the necessary permissions to use the Path+'xxx.mdb'
> > ...have
> > > admin set up permission for you.
> > > The path and database is correct.
> > > Using D5, Access 2000 via ODBC

> > > varDBEngine call to set up authority somehow?
> > > I am setting upUser Name and Password in tDatabase compoment and I
> > > understand that varDBEngine is outside of that.

> > > code below:  (thanks)

> > > function PackAccessDB(db:TDataBase): boolean;
> > > var varDBEngine: variant;
> > >     strDBPathName,
> > >     strTempPathName: string;
> > > begin
> > >   result := true;
> > >   try
> > >     strDBPathName := DataLocation;  \\correct
> > >     strTempPathName := DataDirectory + '\temp.mdb'; \\correct
> > >     varDBEngine := CreateOleObject('DAO.DBEngine.36');
> > >     try
> > >       db.Connected := false;
> > >       varDBEngine.CompactDatabase(strDBPathName, strTempPathName);
> /error
> > > occurs here
> > >       DeleteFile(strDBPathName);
> > >       RenameFile(strTempPathName, strDBPathName);
> > >     except
> > >       result := false;
> > >     end;
> > >   finally
> > >     DB.Params.Free;
> > >     varDBEngine := Unassigned;
> > >     db.Connected := true;
> > >   end;
> > > end;

Other Threads