|
Just how easy is it to restructure a table?
Click on any of the links below to see how easy it is to control
the way your tables are restructured. Note that all these examples assume two
things:
- You have already placed a TRestructure component on a form and
it's name is Restructure1
- You have set properties DatabaseName and TableName to appropriate
values
You should also be aware that changes are written to the table
only after a call to Apply method:
Restructure1.Apply;
At any time (before the call to Apply method) you can cancel the changes to
the table by placing a call to Cancel method:
Restructure1.Cancel;
How to:
Add a field?
with Restructure1.Field do
begin
FieldType := pxAlpha; // Paradox Alpha type
Name := 'NewFieldName';
Length := 20;
end;
Restructure1.AddField(False); // don't set validity checks
back to top
Change a field?
with Restructure1.Field do
begin
FieldType := pxNumber; // Paradox Number type
Name := 'NewFieldName';
end;
// Change the first field and don't change validity checks
Restructure1.ChangeField(1, False);
back to top
Delete a field?
// Drop the third field
Restructure1.DropField(3);
back to top
Insert a field at specific position?
with Restructure1.Field do
begin
FieldType := pxTimestamp; // Paradox Timestamp type
Name := 'NewFieldName';
end;
// Insert the field as second and don't change validity checks
Restructure1.InsertField(2, False);
back to top
Move a field?
// Move the second field to the fifth position
Restructure1.MoveField(2, 5);
back to top
Get the field's name, size, type and
validity checks (if any)?
// After this call, Restructure1.Field.* and
// Restructure1.ValCheck.* properties are filled
// with all the information about the seventh field
Restructure1.GetFieldDesc(7);
back to top
Access a field by its name?
// FieldByName returns field's position in the table
// You can use this function with all of the above
// method calls. For example:
//
// Restructure1.GetFieldDesc(Restructure1.FieldByName('SomeField'));
//
var
Position: Integer;
Position := Restructure1.FieldByName('FieldName');
// Note: FieldByName is not case sensitive
back to top
Check if a field has any validity checks?
var
lVC: Boolean;
lVC := Restructure1.HasValChecks('SomeField');
back to top
Add a validity check?
// Set the default value for a Boolean field
with Restructure1.ValCheck do
begin
DefaultValue := 'true';
end;
Restructure1.AddValCheck('SomeLogicalField');
// Set the default value for a Date field, and make it required
with Restructure1.ValCheck do
begin
DefaultValue := 'today';
Required := True;
end;
Restructure1.AddValCheck('SomeDateField');
back to top
Change a validity check?
with Restructure1.ValCheck do
begin
DefaultValue := '16';
MinimumValue := '13';
MaximumValue := '19';
end;
Restructure1.ChangeValCheck('TeenagerAgeField');
back to top
Delete a validity check?
// Remove all validity checks from TeenagerAgeField
Restructure1.DropValCheck('TeenagerAgeField');
// Remove only default value validity check from TeenagerAgeField
Restructure1.GetFieldDesc(Restructure1.FieldByName('TeenagerAgeField'));
Restructure1.ValCheck.DefaultValue := '';
Restructure1.ChangeValCheck('TeenagerAgeField');
back to top
Check if the table has any referential
integrity constraints set?
var
lRI: Boolean;
lRI := Restructure1.HasRefInts;
back to top
Add a referential integrity constraint?
with Restructure1.RefInt do
begin
MasterTableName := 'MasterTable.DB';
// Do not allow cascade changes
// (DeleteOperation is set to urRestrict by default)
ModifyOperation := urRestrict;
end;
Restructure1.AddRefInt('RefIntName', 'DetailIndexName');
back to top
Remove (delete) a referential integrity
constraint?
Restructure1.DropRefInt('RefIntName');
back to top
Add a master password to the table (protect
the table)?
Restructure1.AddMasterPassword('NewPassword');
back to top
Change table's master password?
Restructure1.ChangeMasterPassword('NewPassword');
back to top
Remove (delete) table's master password
(unprotect the table)?
Restructure1.DropMasterPassword;
back to top
Add an auxiliary password?
// Add a password and set table rights to full
Restructure1.AddAuxPassword('NewAuxiliaryPassword', trFull);
back to top
Change an auxiliary password?
// Change a password and/or change table rights
Restructure1.ChangeAuxPassword('OldAuxiliaryPassword', 'NewAuxiliaryPassword',
trModify);
back to top
Remove (delete) an auxiliary password?
Restructure1.DropAuxPassword('ExistingAuxiliaryPassword');
back to top
Set field rights for any specific auxiliary
password?
Restructure1.ChangeFieldRights('AuxiliaryPassword', 'FieldName',
frReadOnly);
back to top
As you can see from the above examples, any change comes down to
setting a few properties and calling the appropriate method. In fact, most of
these are only one line of code!
Pricing
You can register online by clicking one of the buttons below
and download the full source code within minutes.
We accept AMEX, Diners, Master Card, VISA, Solo, Switch, JCB, Connect,
Eurocard, Delta, UK and US checks, Purchase Orders and PayPal. Click the button
below to order this component online from SWREG in England,
the oldest online software store in the world, or ShareIt!, one of the
biggest online software stores.
| Description |
Option |
Price
|
Register secure online
|
TRestructure Pro
Single Developer License |
with source |
$129.50 |
 |
TRestructure Pro
5 Developers License |
with source |
$388.50 |
TRestructure Pro
Site License |
with source |
$1,295.00 |
TRestructure Lite
Single Developer License |
with source |
$99.50 |
 |
TRestructure Lite
5 Developers License |
with source |
$298.50 |
TRestructure Lite
Site License |
with source |
$995.00 |
Don't want to pass your credit card details over
the Internet or have no credit card? Contact
us.
|