Solved

About table passwords...

Posted on 2000-05-09
3
127 Views
Last Modified: 2010-04-04
I have an empty table named SENSEI.db with all its fields defined. I need to COPY this table at runtime with a different name and a password to begin working with this copy. How can I do this? By the way, is it possible to change the password to a table at runtime? How?
0
Comment
Question by:ajgonzalezm
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
ID: 2795466
See my Electronic Book (Delphi Programming Guide) in which you can find how to define Paradox master password and how to remove it, I copy it from Borland document and it works fine.
This is an example of defining password:

-----------------


At design time you can set a password for a paradox table using Database Desktop tool. At run-time you can set the password using direct BDE API functions. Below procedure can set a master password for Paradox tables, but you have to include BDE, DB, and DBTables in uses clause:


procedure AddMasterPassword(Table: TTable; pswd: string);
const
  RESTRUCTURE_TRUE = WordBool(1);

var
  TblDesc: CRTblDesc;
  hDb: hDBIDb;

begin
  { Make sure that the table is opened and is exclusive }
  if (Table.Active = False) or (Table.Exclusive = False) then
    raise EDatabaseError.Create('Table must be opened in exclusive mode to add passwords');
  { Initialize the table descriptor }
  FillChar(TblDesc, SizeOf(CRTblDesc), 0);

  with TblDesc do
  begin
    { Place the table name in descriptor }
    StrPCopy(szTblName, Table.TableName);
    { Place the table type in descriptor }
    StrCopy(szTblType, szPARADOX);
    { Master Password, Password }
    StrPCopy(szPassword, pswd);
    { Set bProtected to True }
    bProtected := RESTRUCTURE_TRUE;
  end;

  { Get the database handle from the cursor handle }
  Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
  { Close the table }
  Table.Close;
  { Add the master password to the Paradox table }
  Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, FALSE));
  { Add the new password to the session }
  Session.AddPassword(pswd);
  { Re-Open the table }
  Table.Open;
end;


Example of calling password procedure

- Drop a Table.
- Set table's DatabaseName to any Alias and TableName to any Paradox table.
- Add bde to Unit1 uses section and make sure that DBTables and Db also added to uses section.

- Copy and paste above procedure in Unit1.
- Drop a button.
- At button's OnClick event write:

  Table1.Close;
  Table1.Exclusive:= True;
  Table1.Open;
  AddMasterPassword(Table1, 'test');


Notes:

- Befor setting password you have to make sure that the table is opened in exclusive mode.

- Password is case sensitive.

See also

Removing Paradox master password

----------

www.geocities.com/motaz1
EBook/ Delphi.zip
Motaz
0
 

Author Comment

by:ajgonzalezm
ID: 2796477
Thanks a lot Motaz. I haven't had time to try your solution on the computer but I'm sure it will work. Just in case it didn't be sure I will get back to you.

Thanks again.

AJ
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2798863
Welcome any time AJ, I'm very happy that I could help you. If you need any help I'll be there.

Motaz
motaz1@yahoo.com
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now