![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Product Manuals » DBISAM Version 4 Manual for RAD Studio 12 (C++ Win64) » 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 ixPrimary
{ MyDBISAMDataSet->Append(); // State property will now reflect dsInsert MyDBISAMDataSet->FieldByName("CustomerID")->AsString="100"; MyDBISAMDataSet->FieldByName("CustomerName")->AsString="The Hardware Store"; MyDBISAMDataSet->FieldByName("ContactName")->AsString="Bob Smith"; MyDBISAMDataSet->FieldByName("Phone")->AsString="5551212"; MyDBISAMDataSet->FieldByName("Fax")->AsString="5551616"; MyDBISAMDataSet->FieldByName("Email")->AsString= "bobs@thehardwarestore.com"; MyDBISAMDataSet->Post(); // State property will now return to dsBrowse }
void __fastcall TMyForm::MyTablePostError(TDataSet *DataSet, EDatabaseError *E, TDataAction &Action) { Action=daAbort; if (dynamic_cast<EDBISAMEngineError*>(E)) { if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_KEYVIOL) { 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); } } else { ShowMessage(E->Message); } }
{ try { MyDBISAMDataSet->Append(); // State property will now reflect dsInsert MyDBISAMDataSet->FieldByName("CustomerID")->AsString="100"; MyDBISAMDataSet->FieldByName("CustomerName")->AsString= "The Hardware Store"; MyDBISAMDataSet->FieldByName("ContactName")->AsString="Bob Smith"; MyDBISAMDataSet->FieldByName("Phone")->AsString="5551212"; MyDBISAMDataSet->FieldByName("Fax")->AsString="5551616"; MyDBISAMDataSet->FieldByName("Email")->AsString= "bobs@thehardwarestore.com"; MyDBISAMDataSet->Post(); // State property will now return to dsBrowse } catch(const Exception &E) { if (dynamic_cast<EDBISAMEngineError*>(E)) { if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_KEYVIOL) { 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); } } else { ShowMessage(E->Message); } } }
{ MyDBISAMDataSet->Edit(); // State property will now reflect dsEdit // Set LastSaleDate field to today's date MyDBISAMDataSet->FieldByName("LastSaleDate")->AsDateTime=Date; MyDBISAMDataSet->Post(); // State property will now return to dsBrowse }
void __fastcall TMyForm::MyTableEditError(TDataSet *DataSet, EDatabaseError *E, TDataAction &Action) { Action=daAbort; if (dynamic_cast<EDBISAMEngineError*>(E)) { if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_RECLOCKFAILED) { if (MessageDlg("The record you are trying to edit "+ "is currently locked, do you want to "+ "try to edit this record again?", mtWarning,TMsgDlgButtons()<<mbYes<<mbNo,0)==mrYes) { Action=daRetry; } } else if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_KEYORRECDELETED) { MessageDlg("The record you are trying to edit "+ "has been modified since it was last "+ "retrieved, the record will now be "+ "refreshed",mtWarning,TMsgDlgButtons()<<mbOk,0); DataSet->Refresh; Action=daRetry; } else { MessageDlg(E.Message,mtError,TMsgDlgButtons()<<mbOk,0); } } else { MessageDlg(E.Message,mtError,TMsgDlgButtons()<<mbOk,0); } }
{ while (true) { try { MyDBISAMDataSet->Edit(); // State property will now reflect dsEdit // Set LastSaleDate field to today's date MyDBISAMDataSet->FieldByName("LastSaleDate")->AsDateTime=Date; MyDBISAMDataSet->Post(); // State property will now return to dsBrowse break; // Break out of retry loop } catch(const Exception &E) { if (dynamic_cast<EDBISAMEngineError*>(E)) { if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_RECLOCKFAILED) { if (MessageDlg("The record you are trying to edit "+ "is currently locked, do you want to "+ "try to edit this record again?", mtWarning,TMsgDlgButtons()<<mbYes<<mbNo, 0)==mrYes) { continue; } } else if (dynamic_cast<EDBISAMEngineError&>(*E)->ErrorCode== DBISAM_KEYORRECDELETED) { MessageDlg("The record you are trying to edit "+ "has been modified since it was last "+ "retrieved, the record will now be "+ "refreshed",mtWarning,TMsgDlgButtons()<<mbOk,0); MyTable->Refresh(); continue; } else { MessageDlg(E.Message,mtError,TMsgDlgButtons()<<mbOk,0); break; } } else { MessageDlg(E.Message,mtError,TMsgDlgButtons()<<mbOk,0); break; } } } }
{ MyDBISAMDataSet->Delete(); }
{ MyDBISAMDataSet->Edit(); // State property will now reflect dsEdit // Set LastSaleDate field to today's date MyDBISAMDataSet->FieldByName("LastSaleDate")->AsDateTime=Date; MyDBISAMDataSet->Cancel(); // State property will now return to dsBrowse }
{ MyDBISAMDataSet->Edit(); // State property will now reflect dsEdit // Load a text file from disk dynamic_cast<TBlobField&>(*MyDBISAMDataSet->FieldByName("Notes")-> LoadFromFile("c:\\temp\\test.txt"); MyDBISAMDataSet->Post(); // State property will now return to dsBrowse }
{ TDBISAMBlobStream *Stream; // 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=new TDBISAMBlobStream((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 delete MyBlobStream; } MyFirstDBISAMDataSet->Post(); } catch { // Cancel on an exception MyFirstDBISAMDataSet->Cancel(); } }
This web page was last updated on Thursday, November 16, 2023 at 10:39 AM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |