![]() | Products |
| Home » Technical Support » DBISAM Technical Support » Product Manuals » DBISAM Version 4 Manual for RAD Studio XE (Delphi) » Using DBISAM » Updating Tables and Query Result Sets |
Field # Name DataType Size
----------------------------------------------
1 CustomerID ftString 10
2 CustomerName ftString 30
3 ContactName ftString 30
4 Phone ftString 10
5 Fax ftString 10
6 EMail ftString 30
7 LastSaleDate ftDate 0
8 Notes ftMemo 0
Index Name Fields In Index Options
----------------------------------------------
(none) CustomerID ixPrimarybegin
with MyDBISAMDataSet do
begin
Append; { State property will now reflect dsInsert }
FieldByName('CustomerID').AsString:='100';
FieldByName('CustomerName').AsString:='The Hardware Store';
FieldByName('ContactName').AsString:='Bob Smith';
FieldByName('Phone').AsString:='5551212';
FieldByName('Fax').AsString:='5551616';
FieldByName('Email').AsString:='bobs@thehardwarestore.com';
Post; { State property will now return to dsBrowse }
end;
end;procedure TMyForm.MyTablePostError(DataSet: TDataSet;
E: EDatabaseError; var Action: TDataAction);
begin
Action:=daAbort;
if (E is EDBISAMEngineError) then
begin
if (EDBISAMEngineError(E).ErrorCode=DBISAM_KEYVIOL) then
ShowMessage('A record with the same key value(s) '+
'already exists, please change the '+
'record to make the value(s) unique '+
'and re-post the record')
else
ShowMessage(E.Message);
end
else
ShowMessage(E.Message);
end;begin
try
with MyDBISAMDataSet do
begin
Append; { State property will now reflect dsInsert }
FieldByName('CustomerID').AsString:='100';
FieldByName('CustomerName').AsString:='The Hardware Store';
FieldByName('ContactName').AsString:='Bob Smith';
FieldByName('Phone').AsString:='5551212';
FieldByName('Fax').AsString:='5551616';
FieldByName('Email').AsString:='bobs@thehardwarestore.com';
Post; { State property will now return to dsBrowse }
end;
except
on E: Exception do
begin
if (E is EDBISAMEngineError) then
begin
if (EDBISAMEngineError(E).ErrorCode=DBISAM_KEYVIOL) then
ShowMessage('A record with the same key value(s) '+
'already exists, please change the '+
'record to make the value(s) unique '+
'and re-post the record')
else
ShowMessage(E.Message);
end
else
ShowMessage(E.Message);
end;
end;
end;begin
with MyDBISAMDataSet do
begin
Edit; { State property will now reflect dsEdit }
{ Set LastSaleDate field to today's date }
FieldByName('LastSaleDate').AsDateTime:=Date;
Post; { State property will now return to dsBrowse }
end;
end;procedure TMyForm.MyTableEditError(DataSet: TDataSet;
E: EDatabaseError; var Action: TDataAction);
begin
Action:=daAbort;
if (E is EDBISAMEngineError) then
begin
if (EDBISAMEngineError(E).ErrorCode=DBISAM_RECLOCKFAILED) then
begin
if MessageDlg('The record you are trying to edit '+
'is currently locked, do you want to '+
'try to edit this record again?',
mtWarning,[mbYes,mbNo],0)=mrYes then
Action:=daRetry;
end
else if (EDBISAMEngineError(E).ErrorCode=DBISAM_KEYORRECDELETED) then
begin
MessageDlg('The record you are trying to edit '+
'has been modified since it was last '+
'retrieved, the record will now be '+
'refreshed',mtWarning,[mbOk],0);
DataSet.Refresh;
Action:=daRetry;
end
else
MessageDlg(E.Message,mtError,[mbOK],0);
end
else
MessageDlg(E.Message,mtError,[mbOK],0);
end;begin
while True do
begin
try
with MyDBISAMDataSet do
begin
Edit; { State property will now reflect dsEdit }
{ Set LastSaleDate field to today's date }
FieldByName('LastSaleDate').AsDateTime:=Date;
Post; { State property will now return to dsBrowse }
end;
Break; { Break out of retry loop }
except
on E: Exception do
begin
if (E is EDBISAMEngineError) then
begin
if (EDBISAMEngineError(E).ErrorCode=
DBISAM_RECLOCKFAILED) then
begin
if MessageDlg('The record you are trying '+
'to edit is currently locked, '+
'do you want to try to edit '+
'this record again?,mtWarning,
[mbYes,mbNo],0)=mrYes then
Continue;
end
else if (EDBISAMEngineError(E).ErrorCode=
DBISAM_KEYORRECDELETED) then
begin
MessageDlg('The record you are trying '+
'to edit has been modified '+
'since it was last retrieved, '+
'the record will now be '+
'refreshed',mtWarning,[mbOk],0);
MyTable.Refresh;
Continue;
end
else
begin
MessageDlg(E.Message,mtError,[mbOK],0);
Break;
end;
end
else
begin
MessageDlg(E.Message,mtError,[mbOK],0);
Break;
end;
end;
end;
end;
end;begin
with MyDBISAMDataSet do
Delete;
end;begin
with MyDBISAMDataSet do
begin
Edit; { State property will now reflect dsEdit }
{ Set LastSaleDate field to today's date }
FieldByName('LastSaleDate').AsDateTime:=Date;
Cancel; { State property will now return to dsBrowse }
end;
end;begin
with MyDBISAMDataSet do
begin
Edit; { State property will now reflect dsEdit }
{ Load a text file from disk }
TBlobField(FieldByName('Notes')).LoadFromFile('c:\temp\test.txt');
Post; { State property will now return to dsBrowse }
end;
end;var
MyBlobStream: TDBISAMBlobStream;
begin
{ First create the BLOB stream - be sure to make sure that
we put the table into dsEdit or dsInsert mode first since
we're writing to the BLOB stream }
MyFirstDBISAMDataSet.Append;
try
MyBlobStream:=TDBISAMBlobStream.Create(TBlobField(
MyFirstDBISAMDataSet.FieldByName('TableStream')),bmWrite);
try
{ Now save the table to the BLOB stream }
MySecondDBISAMDataSet.SaveToStream(MyBlobStream);
finally
{ Be sure to free the BLOB stream *before* the Post }
MyBlobStream.Free;
end;
MyFirstDBISAMDataSet.Post;
except
{ Cancel on an exception }
MyFirstDBISAMDataSet.Cancel;
end;
end;This web page was last updated on Tuesday, September 16, 2025 at 04:56 PM | Privacy Policy © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? |

