Board index » delphi » Access violation

Access violation

I have a problem with a Query, if I try to use the Open methog at run time
an access violation is raised. But there are no problems in changing the
active property to true at design time. How can this be? I'm using delphi 4
c/s, sql server 7, the query has requestlive set to true, only refers to one
table, with an order by on a field with an index on it.
 

Re:Access violation


Quote
Marc-Andre Hebert wrote:

> I have a problem with a Query, if I try to use the Open methog at run time
> an access violation is raised. But there are no problems in changing the
> active property to true at design time. How can this be? I'm using delphi 4
> c/s, sql server 7, the query has requestlive set to true, only refers to one
> table, with an order by on a field with an index on it.

        There are a number of things which happen when you open a query at
runtime which do not happen when you open the same query at design
time.  Some examples include:

o  Handlers you've assigned for your TQuery's BeforeOpen, AfterOpen,
BeforeScroll, AfterScroll events run.
o  Handlers you've assigned for your TDataSet's OnDataChange and
OnStateChange events run.
o  Handlers you've assigned for events such as OnChange run in your
data-aware controls (there may be other events, depending upon the
control).

        If you get an access violation when running within the IDE, Delphi
should stop on or around the line of code which caused the violation.
Put a breakpoint somewhere ahead of that line of code and step through
your code until you find exactly which line is causing the violation.
Put a break on that line and run again.  Now inspect each object in the
line and make sure they're all assigned.

        HTH,

        -Craig
--
Craig Stuntz            Vertex Systems Corporation
Senior Developer        http://www.vertexsoftware.com

Other Threads