Solved

Delphi: Using form components in COM+

Posted on 2004-09-15
5
365 Views
Last Modified: 2010-05-18
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
Comment
Question by:harveykane
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12072144
"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
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 125 total points
ID: 12072897
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
 
LVL 2

Author Comment

by:harveykane
ID: 12073189
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
 
LVL 2

Author Comment

by:harveykane
ID: 12168209
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
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12168444
"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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now