[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

Delphi: Using form components in COM+

I'm writing a COM+ application in delphi that reads some information from a file, processes it and saves it to another file.

I'm running the app via a PHP webpage - the webpage simply calls a single method within the app via COM+.

As part of the application, I need to use a few non-visible components (such as Data Sources etc). Because the app runs in the background, there is no need for a user interface, so forms should not be needed.

But I need somewhere to stick my data components. So I created a form called "dm" and associated unit "dmU". I add my data components to the form and use the object inspector to set the properties how I want them. All good so far.

The program builds and I can run it ok, except the program will crash every time I try to access the component on the form, or even the form itself via code.

eg
dm.mycomponent.clear;

likewise "dm.show;" will crash the program, as you would expect.

Because I'm running the program via PHP, I don't get any more details on the error. It just says an exception occured, and by commenting backwards I have found this line to be the culprit.

So my question is....

How can I access these hidden data components without crashing the program?

Is there a property of the form I need to set, or perhaps a special form I need to use instead?
0
harveykane
Asked:
harveykane
  • 2
  • 2
1 Solution
 
Ivanov_GCommented:
"So I created a form"...
What form do you create... If you are inside the COM+ and need some place to put DB controls, use Remote Data Module (on Multitier tab).

"How can I access these hidden data components without crashing the program."
Open the _TLB.pas file, press F12 and you see the declaration of the COM component. Put there a new method called for example "ClearDataSets" and press refresh... It will appear in the Remote Data Module I mentioned above. And you will put your code inside this method.
0
 
Wim ten BrinkCommented:
Don't use a form, use a data module for these components!
And remember that a datamodule is just a class, not an object. You will have to create it at some point. As Ivanov already says, you could use a remote data module instead.

However, I wonder why you haven't noticed this yourself, while you're working on something complicated as COM. Are you using Delphi 2 or 3?
0
 
harveykaneAuthor Commented:
This is just a one off project for me, I normally do PHP based projects or if I use delphi, I do standard exe programs. I need to use COM for this project so it will fit in with how the server is set up. I'm using Delphi 7.

Thanks for the feedback so far - I will try the remote data module and keep you posted.
0
 
harveykaneAuthor Commented:
OK, I have solved the problem by using a Data Module instead of a form. I couldn't find any option for a remote data module though - the help says I can find it in File - New - Other - Multitier - Remote data module
I'm using Delphi 7 Professional, and there is no "multitier" tab to be found. Is this feature unique to enterprise edition, or am I missing something.
Points will be awarded anyway, this question is just for interests sake :)
0
 
Ivanov_GCommented:
"I couldn't find any option for a remote data module though"
Probably you are not using Enterpris versions of Delphi. Is some educational versions it doesn't exists I think... I don't know about professional.

Using Data Module will be OK for you if you don't want to use the data sets from the client. Else, if you need MIDAS act as application server - you need Remote Data Module.


0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now