Product Documentation

dbExpress Driver (dBX)

Previous Topic

Next Topic

Manage

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_CustomerMaster_Records();

// display contents of table

Display_Records();

end;

procedure TForm1.btmUpdateClick(Sender: TObject);

begin

// update a record under locking control

Update_CustomerMaster_Record();

// display again after update and effects of lock

Display_Records();

end;


procedure TForm1.Add_CustomerMaster_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.Delete_Records;

begin

try

SQLConnection1.ExecuteDirect('DELETE FROM custmast');

except on E: Exception do Handle_Exception(E);

end;

end;

procedure TForm1.Display_Records;

begin

try

SimpleDataSet1.Active := false;

SimpleDataSet1.DataSet.CommandType := ctQuery;

SimpleDataSet1.DataSet.CommandText := 'SELECT * FROM custmast';

SimpleDataSet1.Active := true;

except on E: Exception do Handle_Exception(E);

end;

end;

procedure TForm1.Update_CustomerMaster_Record;

var

str : string;

begin

try

SQLConnection1.StartTransaction(td);

str := 'UPDATE custmast SET cm_custname = ''KEYON DOOLING'' where cm_custnumb = ''1003''';

SQLConnection1.ExecuteDirect(str);

Application.MessageBox('Click OK to unlock', '', 0);

SQLConnection1.Commit(td);

except on E: Exception do Handle_Exception(E);

end;

end;

TOCIndex