Solved

Delphi: Using form components in COM+

Posted on 2004-09-15
5
372 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

810 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