Solved

About table passwords...

Posted on 2000-05-09
3
132 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 349
Show Listview image from database (String field) 5 143
enhance the following code 3 41
Broadcast a message using ICS 2 20
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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