Board index » delphi » How can I access password protected paradox table?

How can I access password protected paradox table?

Hi
    I use password protected paradox table by TQuery and connect directly to
the table (set database file path to DatabaseName field) -->
Query1.DatabaseName := 'C:\Database';

code
====
var
  db: TDatabase;
begin
    db := TDatabase.Create(Self);
    db.DatabaseName := 'D:\Delphi';
    db.LoginPrompt := False;
    // db.Params.Values['user name'] := ''; // paradox table has no user
name
    db.Params.Values['password'] := 'mypassword';

    Query1.DatabaseName := db.DatabaseName;
    Query1.SQL.Add('select * from Test');
    Query1.Open;

// *********** It does not work *************
There's an exception error with message "Insufficient table rights for
operation. Password required. Table: D:\Delphi\Test.db.".

Regards
Rock

 

Re:How can I access password protected paradox table?


Quote
>     I use password protected paradox table by TQuery and connect directly to
> the table (set database file path to DatabaseName field) -->
> Query1.DatabaseName := 'C:\Database';

> code
> ====
> var
>   db: TDatabase;
> begin
>     db := TDatabase.Create(Self);
>     db.DatabaseName := 'D:\Delphi';
>     db.LoginPrompt := False;
>     // db.Params.Values['user name'] := ''; // paradox table has no user
> name
>     db.Params.Values['password'] := 'mypassword';

>     Query1.DatabaseName := db.DatabaseName;
>     Query1.SQL.Add('select * from Test');
>     Query1.Open;

> // *********** It does not work *************
> There's an exception error with message "Insufficient table rights for
> operation. Password required. Table: D:\Delphi\Test.db.".

You have propably set Session.OnPassword somewhere...

Try following code:

begin
   Session.AddPassword('mypassword');
   Query1.DatabaseName := 'C:\Delphi';
   Query1.SQL.Add('select * from Test');
   Query1.Open;
end;

Note that You should call Session.AddPassword only once with the
password - session can hold only limited number of passwords, if You
readd the same password again and again, You will get an error.

--
Gert

Re:How can I access password protected paradox table?


"Rock" <evilhun...@lycos.co.uk> ha scritto nel messaggio
news:3e649d5d@newsgroups.borland.com...

Quote
> Hi
>     I use password protected paradox table by TQuery and connect directly
to
> the table (set database file path to DatabaseName field) -->
> Query1.DatabaseName := 'C:\Database';

> code
> ====
> var
>   db: TDatabase;
> begin
>     db := TDatabase.Create(Self);
>     db.DatabaseName := 'D:\Delphi';
>     db.LoginPrompt := False;
>     // db.Params.Values['user name'] := ''; // paradox table has no user
> name
>     db.Params.Values['password'] := 'mypassword';

>     Query1.DatabaseName := db.DatabaseName;
>     Query1.SQL.Add('select * from Test');
>     Query1.Open;

> // *********** It does not work *************
> There's an exception error with message "Insufficient table rights for
> operation. Password required. Table: D:\Delphi\Test.db.".

> Regards
> Rock

It seems that you're using TDatabase incorrectly:
try this:
var
   db: TDatabase;
 begin
     db := TDatabase.Create(Self);
     db.DatabaseName := 'D:\Delphi';
     db.AliasName := 'MyAlias';
     db.LoginPrompt := False;
     // db.Params.Values['user name'] := ''; // paradox table has no user
 name
     db.Params.Values['password'] := 'mypassword';

     Query1.DatabaseName := 'MyAlias';
     Query1.SQL.Add('select * from Test');
     Query1.Open;

Ferruccio

Re:How can I access password protected paradox table?


Your suggestions are valuable for me, Thank you so much.
Rock

Other Threads