Solved

About table passwords...

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: Connect to running MS Outlook 4 199
I want to use librsync in my Delphi backup application. 3 82
RESTRequest Parameter 4 77
delphi popmenu non latine charcters 3 45
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 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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 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