Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Encrypted table
Thu, Mar 17 2022 8:41 PMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

hi

I have a encrypted table which i would like to open by code. It is for local use so
DBsession.SessionType = stLocal

I have a datamodule with contains the:
- TDBISAMdatabase (called DB)
- TDBISAMsession (called DBsession)
- TDBISAMtable
- TDataSource

Within the datamodules.OnCreate event i use the code below which opens my tables BUT
always the graphical UI for entering the password is showed.

DBsession.AddPassword('myPassword');
DBsession.Active;
DB.Connected := True;
DBsession.Active := True;

for i := 0 to ComponentCount -1 do begin
    if Components[i] is TDBISAMTable then begin
      (Components[i] as TDBISAMTable).Active;
   end;
end;

When reading the help file this should be enough...using something like
DBsession.OnPassword and add the password in this event also not working

What am i missing?
Thu, Mar 17 2022 10:09 PMPermanent Link

Raul

Team Elevate Team Elevate

On 3/17/2022 8:41 PM, Peter van Mierlo wrote:

> Within the datamodules.OnCreate event i use the code below which opens my tables BUT
> always the graphical UI for entering the password is showed.
>
> DBsession.AddPassword('myPassword');
> DBsession.Active;
> DB.Connected := True;
> DBsession.Active := True;
>
> for i := 0 to ComponentCount -1 do begin
>       if Components[i] is TDBISAMTable then begin
>         (Components[i] as TDBISAMTable).Active;
>      end;
> end;
>
> When reading the help file this should be enough...using something like
> DBsession.OnPassword and add the password in this event also not working
>
> What am i missing?

Most likely your table is not actually lusing the DbSession (is it using
the default session maybe?).

I usually recommend just using OnPassword event handler and add password
there as this guarantees no dialogs is shown - we use this a lot and it
works fine here.

Raul
Fri, Mar 18 2022 4:01 AMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

Hi Raul

I will try..but for the session:

DBsession.AutoSession = True
DBsession.SessionName = DBsession_1

TDBISAMtable.SessionName = DBsession_1

That must  be correct ?

When i use DBsession.OnPassword and add the password using:
DBsession.AddPassword('mypassword')

When running the application i get the following message
'DBISAM Engine Error # 10498 insufficient rights to the table {table name}, a password is required'

Regards Peter
Fri, Mar 18 2022 4:06 AMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

and the password is correct...checked twice and encrrypted the table again ...that can't be the reason for the message
Fri, Mar 18 2022 9:20 AMPermanent Link

Raul

Team Elevate Team Elevate

On 3/18/2022 4:01 AM, Peter van Mierlo wrote:
> Hi Raul
>
> I will try..but for the session:
>
> DBsession.AutoSession = True
> DBsession.SessionName = DBsession_1
>
> TDBISAMtable.SessionName = DBsession_1
>
> That must  be correct ?
>
> When i use DBsession.OnPassword and add the password using:
> DBsession.AddPassword('mypassword')
>
> When running the application i get the following message
> 'DBISAM Engine Error # 10498 insufficient rights to the table {table name}, a password is required'

Peter,

There is no AutosSession property - i assume you mean AutoSessionName!?

Why would you ask session to generate name and then set a name yourself !?

Try this instead

DBsession.AutoSessionName := true;
TDBISAMtable.SessionName = DBsession.SessionName;
etc...

Raul
Fri, Mar 18 2022 12:31 PMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

Hi Raul

You correct regardign the AutoSesison property.

I don't think I see it anymore...but what am I doing wrong in the example in the attachment

Regards Peter



Attachments: tabelencrypt.zip
Fri, Mar 18 2022 4:14 PMPermanent Link

Raul

Team Elevate Team Elevate

On 3/18/2022 12:31 PM, Peter van Mierlo wrote:
> Hi Raul
>
> You correct regardign the AutoSesison property.
>
> I don't think I see it anymore...but what am I doing wrong in the example in the attachment
>

Just add  "Continue := true;" to the DBsessionPassword event and it
should work.

i.e.

procedure TdmMain.DBsessionPassword(Sender: TObject; var Continue: Boolean);
begin
  DBsession.AddPassword('test');
  Continue := true;
end;

Raul
Sat, Mar 19 2022 10:49 AMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

Hi Raul

Thank you...the Continue := true;
did it and it's working now

Greetz Peter
Image