Solved

About table passwords...

Posted on 2000-05-09
3
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

689 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