A step-by-step walk through of separating business logic to another server using BOLD + DCOM with an Interbase database.
This article was compiled from logs of an internet chat (IRC) with Eric Holton. I would like to thank Eric for spending so much time detailing the steps envolved. Eric has agreed to let me convert the logs of our conversation into this article for the benefit of others.
- Create a new application with a form and a datamodule.
- Name the module dmServer, and the main form fmServerMain.
- Save the form as ServerMainForm.pas, the module as ServerModule.pas, and the project as ServerApp.DPR
- From the [Bold Handles] tab add a TBoldModel (mbModel), TBoldSystemTypeInfoHandle (ihModelInfo), TBoldSystemHandle (shMainHandle), and a TBoldPersistenceHandleIB (phInterbase).
- In the object inspector set the following properties:
DatabaseName = an existing GDB file to be replaced.
BoldModel = bmModel
DatabaseEngine = dbeInterbaseSQLDialect3
SystemTypeInfoHandle = ihModelInfo
PersistenceHandle = phInterbase
IsDefault = True
AutoActivate = True
BoldModel = bmModel
- In the OnDestroy of the datamodule include the following code
if Assigned(shMainHandle.System) then
with shMainHandle.System do
if BoldDirty then Discard;
- Double click the model to bring up the model editor, and do the following:
- Change "Name" and "Unit name" from BusinessClasses to DCOMTestClasses
- Change "Model root class" from BusinessClassesRoot to DCOMTestClassesRoot
- Add a new class called Person with a single attribute "firstName"
- Tools menu, Generate database
- Tools menu, Generate code - save the resulting files with their default names
- Tools menu, Generate COM/IDL GUIDs (say YES to "Keep existing GUIDs?")
- Tools menu, Generate Delphi compatible IDL - save the results files with their default names
- Save the model, and then close the model editor
- File menu, New, [ActiveX] tab, "Type library" and do the following:
- Click the [Uses] tab
- Right-click and select "Show All Type Libraries"
- Tick "Bold ObjectSpace Type Library"
- Right-click and select "Show selected"
- Open the file DCOMTesterClasses.IDL
- Select all of the text and copy it to the clipboard
- Click the [Text] tab on the TLB editor
- Replace all of the text with the text in the clipboard
- Click "Refresh implementation"
- CTRL+S and save the TLB as the default name (ProjectName.TLB)
- From the [Bold COM] tab drop the following components onto the server module TBoldCOMServerHandle (cshServerHandle) and a TBoldComServerElementHandle (cseElementHandle) and set the following properties:
BoldHandle = shMainHandle
ServerHandle = cshServerHandle
- Double-click cshServerHandle and generate code, save this file as DCOMTestServerCode.pas
- Copy the GUID from DCOMTestServerCode to the clipboard
- Save and run the application, all should be well.
- Register the server's TLB file using RegSvr32 or TRegSvr (borland\delphi\bin folder).
- Create a new application with a form and a datamodule (the form should "Use" the module).
- Name the module dmClient, and the main form fmClientMain.
- Save the form as ClientMainForm.pas, the module as ClientModule.pas, and the project as ClientApp.DPR
- From the [Bold COM] tab add a TBoldCOMConnectionHandle (chCOMConnection), and a TBoldSystemHandleCom (shMainHandle) set the following properties
ServerCLSID = the GUID from DCOMTestServerCode.pas (The ServerName property should alter automatically)
AutoConnect = True
ConnectionHandle = chCOMConnection
IsDefault = TRUE
ObjectName = (Same as ObjectName of cseElementHandle in the server)
- From the [Bold COM Handles] tab drop a TBoldListHandleCom (blhPerson) on to your main form, set
ConnectionHandle = dmClient.chCOMConnection
Expression = 'Person.allInstances'
RootHandle = dmClient.shMainHandle
- From the [Bold COM Controls] tab drop a TBoldGridCom and a TBoldNavigatorCom on to your main form and set the BoldHandle property of both to blhPerson.
- Right-click BoldGridCOM1 and select "Edit columns" set the Expression property of the second column to "firstName".
- Add a button to your form with the following code attached
Your application should now work.