?
Solved

Delphi: Using form components in COM+

Posted on 2004-09-15
5
Medium Priority
?
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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