Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP. Access Violation in DataModule

41 views
Skip to first unread message

Ivo Ramirez Lamas

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
I hope that somebody nows what is going on.

I have a DataModule named DM, it has about 24 components on it (queries,
datasources, 1 database component, etc).
I´m developing an executable application and the data module DM is not
in the auto create forms list, so it´s not been created at the beggining
of the application and I have to create it by my self in order to work
with it.
I realized that the DM object returns an Access Violation before it´s
created, I thought that was normal and thougth that the Access Violation
message will dissapear after creating the object with this sentence:
DM := TDM.Create(nil);
but the message still remains,
is it normal?
if not, What do I have to do to remove the Access Violation?
But there is something stranger, if write the name of the data module in
my code it fails. For example if I wanna see if the property connected
of the database component is set to TRUE or FALSE, I use this sentence
in the watch window:
DM.database_comp.connected
What I see is, again, the Access Violation message. But if I edit the
watch with this:
database_comp.connected
I see TRUE or FALSE depending of the conexion status.
I´m stuck with it and desperate to so please HEEEELLLLLPPPPPP!

---------------------------------------
Lic. Ricardo Ivo Ramírez Lamas
---------------------------------------

Luis Heriberto Preciado Delgado

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
Pregúntale a Luis Heriberto Preciado Delgado, por favor

Ivo Ramirez Lamas wrote:

--
Lia. Luis Heriberto Preciado Delgado

Peter Below (TeamB)

unread,
Sep 29, 2000, 3:00:00 AM9/29/00
to
In article <39D22829...@tutopia.com>, Ivo Ramirez Lamas wrote:
> I have a DataModule named DM, it has about 24 components on it (queries,
> datasources, 1 database component, etc).
> I惴 developing an executable application and the data module DM is not
> in the auto create forms list, so it愀 not been created at the beggining

> of the application and I have to create it by my self in order to work
> with it.
> I realized that the DM object returns an Access Violation before it愀

> created, I thought that was normal

Avs are never normal, they are exceptions showing you that something is
seriously wrong with your application.

> and thougth that the Access Violation
> message will dissapear after creating the object with this sentence:
> DM := TDM.Create(nil);
> but the message still remains,

A may be a sequence problem. If the main form (which is certainly
autocreated) contains references to the datamodule it may try to access it
before you go round to create it, for example.

> What do I have to do to remove the Access Violation?

Find what causes it and fix the problem, of course.

> But there is something stranger, if write the name of the data module in
> my code it fails. For example if I wanna see if the property connected
> of the database component is set to TRUE or FALSE, I use this sentence
> in the watch window:
> DM.database_comp.connected
> What I see is, again, the Access Violation message.

Then DM has not been initialized correctly. Are you sure you are using the
*same* DM variable to assign the created datamodule reference to and to
later refer to it?

> But if I edit the watch with this:
> database_comp.connected
> I see TRUE or FALSE depending of the conexion status.

The breakpoint you have landed on seem to be inside a method of the
datamodule. From inside an objects methods you never use the variable
holding the object reference directly, it is not necessary and it can cause
errors since the object may already execute code (e.g. its Constructor or
OnCreate event handler) before the variable has a valid reference to the
object.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!


0 new messages