I am writing a program that uses two modules, a VCL win32 application module and a Datamodule to contain ADO components and a clientdataset to work the data in memory.

When compiling the code fails with the message Raised Exception class EAccessViolation in Module EstimateMngr.exe. The debugger shows failrue in the following code:

procedure TForm3.ResetDataSets;
begin
  //Fails in next line at the IF statement
  IF DataModule3.TaskClientDataSet.Active THEN DataModule3.TaskClientDataSet.Close;
    DataModule3.ADOTaskTable.ConnectionString := AccessCxHelper.CXString;
    DataModule3.TaskClientDataSet.Open;
End;

The DataModule unit is in the uses clause. Tracing the execution shows that once it finishes reading the first line, it jumps to a function VirtualQuery in the Windows unit, then to GetModuleFileName in Windows, and then into the process to raise the exception.

Does anyone have suggestions?

I have an idea... i should work...If you are using Delphi - go to 'Project' - 'Options' - then a menu will appear that shows you your forms, put ALL your forms before your Data module page, they will then run before the data module and your problem is solved, also try this - set all connections to false, then code on your form show event

DBMODULENAME.TABLENAME.Open;

and on form close

DBMODULENAME.TABLENAME.close;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.