TurboDB ADO.NET Data Provider

TurboDBConnection.PasswordNeeded Event

Previous  Top  Next

Occurs when a secured or encrypted table should be opened.

C#

public event TurboDBPasswordNeededEventHandler PasswordNeeded

Event Data

The event handler receives an argument of type TurboDBPasswordNeededEventArgs with these fields:

Property

Description

TableName

Name of the TurboDB table to open

Password

The password passed from the event handler to the connection

Retry

If true, the connection will try to open the table with the given password and key. Otherwise the connection will cancel trying to open the TurboDB table.

Notes

This event is issued each time, when the database engine tries to open a protected database table. This is normally the case during the execution of a SQL command. When handling the event, fill the Password field with the password for the table and set Retry to true.

Compatibility

In earlier versions of TurboDB there was an encryption mode, which required an alphanumeric password and a numeric key. This mode is called the classic mode and requires now to enter the former password and key within one password like this <password>;<key>, e.g: secret;-123.

TurboDB Managed does never call this event, because it currently has no support for encrypted or protected tables.

Sample

This is a possible implementation of a handler for the PasswordNeeded event, if your application knows the password and the code of all tables it is using. We assume here, that Table1 had been encrypted with AES and Table2 in classic mode.

C#

private void turboDBConnection1_PasswordNeeded(object sender, DataWeb.TurboDB.TurboDBPasswordNeededEventArgs e)
{
  if (e.TableName.CompareTo("Table1") == 0) {
    e.Password = "Table1PW";
    e.Retry = true;
  } else if (e.TableName.CompareTo("Table2") == 0) {
    e.Password = "Table2PW;99999992";
    e.Retry = true;
  } else {
    MessageBox.Show("Don't know password and key for database table.");
    e.Retry = false;
  } 
}

See also

TurboDBConnection Class | TurboDBConnection Members | Protected Database Tables | Data Security