Manage() provides data management functionality for your application and/or process.
Below is the code for Manage():
procedure TForm1.Manage;
begin
// delete any existing records
Delete_Records;
// populate the table with data
Add_Records;
// display contents of table
Display_Records;
end;
procedure TForm1.Delete_Records;
begin
try
SQLConnection1.StartTransaction(td);
SQLConnection1.ExecuteDirect('DELETE FROM custmast');
SQLConnection1.Commit(td);
except on E: Exception do Handle_Exception(E);
end;
end;
procedure TForm1.Add_Records;
const
data : array [1..4] of string = (
'(''1000'', ''92867'', ''CA'', ''1'', ''Bryan Williams'', ''2999 Regency'', ''Orange'')',
'(''1001'', ''61434'', ''CT'', ''1'', ''Michael Jordan'', ''13 Main'', ''Harford'')',
'(''1002'', ''73677'', ''GA'', ''1'', ''Joshua Brown'', ''4356 Cambridge'', ''Atlanta'')',
'(''1003'', ''10034'', ''MO'', ''1'', ''Keyon Dooling'', ''19771 Park Avenue'', ''Columbia'')'
);
nRecords : integer = 4;
var
i : integer;
str : string;
begin
try
SQLConnection1.StartTransaction(td);
for i := 1 to nRecords do
begin
// add one record at time to table
str := 'INSERT INTO custmast VALUES ' + data[i];
SQLConnection1.ExecuteDirect(str);
end;
SQLConnection1.Commit(td);
except on E: Exception do Handle_Exception(E);
end;
end;
procedure TForm1.Display_Records;
begin
try
SimpleDataSet1.DataSet.CommandType := ctQuery;
SimpleDataSet1.DataSet.CommandText := 'SELECT * FROM custmast';
SimpleDataSet1.Active := true;
except on E: Exception do Handle_Exception(E);
end;
end;