In Delphi, is there a way to save variables INSIDE the MS Access .mdb file, e.g. global variables

Hi!

I have a simple Delphi program that reads a simple MS Access .mdb database.

I just want to save some simple "global variables" in the mdb file, from my Delphi program.

e.g. If I can just save the name of the last technician who worked on the database or whatever.

Obviously, I don't want to save this data in a field in the database table.

Is there a way to do this?

Save a variable in a query perhaps?

Thanks!
toratoratoraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
> Obviously, I don't want to save this data in a field in the database table.
Why obviously ? Why not ?

I would say that is the only way. You have a table named GLOBAL, with only one record, and one field for all variables you want to load/save.

Save in a query doesn't mean much. It's always stored in a table, even if you used a TQuery to do it (but it's not good to do that way).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Emmanuel PASQUIERFreelance Project ManagerCommented:
Here is a complete example
Var
 Last_User:String;
 Last_Session_End:TDateTime;

// Set NewRec to true to keep an history of the global values. 
procedure SaveGlobals(NewRec:Boolean=False); 
begin
 With tbGlobals do
  begin
   Open;
   Last;
   if NewRec Then Append Else Edit;
   FieldByName('Last_User').AsString:=Last_User;
   FieldByName('Last_Session_End').AsDateTime:=Last_Session_End;
   Post;
   Close;
  end;
end;

// always load the last record, so will work the same if you kept an history or not
procedure LoadGlobals;
begin
 With tbGlobals do
  begin
   Open;
   if Not IsEmpty Then
    begin
     Last;
     Last_User:=FieldByName('Last_User').AsString;
     Last_Session_End:=FieldByName('Last_Session_End').AsDateTime;
    end;
   Close;
  end;
end;

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.