Board index » delphi » Creating a database problem - please help!

Creating a database problem - please help!

Hello all fellow coders

I just love it when queries and code start working and we all know that the
satisfaction of achievement becomes a drug.  Sadly, my next "fix" keeps
avoiding me.  Please help!

I need to create a local Paradox database consisting of multiple tables
during run-time.  I prefer using SQL as I know it well and would like to
expand the system later on to be distributed.

Currently, I am doing something like the following:

procedure TDBDataModule.CreateTables(Path: string);
var
  Tmp: string;
  ParamList : TParams;
begin
     ParamList := TParams.Create;
     DatabaseMake.DatabaseName := Path;
     DatabaseMake.Open;

     try
        Tmp := 'CREATE TABLE "client.db" .....) ';    // SQL left out to
save space
        DatabaseMake.Execute(Tmp, ParamList, False, nil);

        Tmp := 'CREATE TABLE "employee.db" .....) ';
        DatabaseMake.Execute(Tmp, ParamList, False, nil);

        ... (creating 8 more tables in a similar fashion)

     finally
           ParamList.Free;
     end;
end;

The problem with this is that I get an EAccessViolation (...read of address
FFFFFFFF) which suggests a null pointer somewhere, but I don't understand
why.  The strangest thing however, is that sometimes the tables are created,
and sometimes not.

Perhaps there is a different way to create a set of tables run-time? ...or
am I missing something obvious above?

Please help!!

Regards
Jaco van Niekerk

 

Re:Creating a database problem - please help!


On Thu, 15 May 2003 13:01:37 +0200, "Jaco van Niekerk"

Quote
<spa...@lantic.net> wrote:
>Hello all fellow coders

>I just love it when queries and code start working and we all know that the
>satisfaction of achievement becomes a drug.  Sadly, my next "fix" keeps
>avoiding me.  Please help!

>I need to create a local Paradox database consisting of multiple tables
>during run-time.  I prefer using SQL as I know it well and would like to
>expand the system later on to be distributed.

Using queries and SQL is the right way to go.

Quote
>Currently, I am doing something like the following:

>procedure TDBDataModule.CreateTables(Path: string);
>var
>  Tmp: string;
>  ParamList : TParams;
>begin
>     ParamList := TParams.Create;
>     DatabaseMake.DatabaseName := Path;
>     DatabaseMake.Open;

>     try
>        Tmp := 'CREATE TABLE "client.db" .....) ';    // SQL left out to
>save space
>        DatabaseMake.Execute(Tmp, ParamList, False, nil);

>        Tmp := 'CREATE TABLE "employee.db" .....) ';
>        DatabaseMake.Execute(Tmp, ParamList, False, nil);

>        ... (creating 8 more tables in a similar fashion)

>     finally
>           ParamList.Free;
>     end;
>end;

>The problem with this is that I get an EAccessViolation (...read of address
>FFFFFFFF) which suggests a null pointer somewhere, but I don't understand
>why.  The strangest thing however, is that sometimes the tables are created,
>and sometimes not.

This error usually means you are trying to access some object which
hasn't been created yet, or has already been destroyed. Use
breakpoints to step through your code to find the statement which
causes the AV. Good luck :-)

Quote
>Perhaps there is a different way to create a set of tables run-time? ...or
>am I missing something obvious above?

If I am going to need a local table at runtime, I usually go ahead and
make an empty one and have it there all the time. Another method is
the BatchMove component. It will create the destination table for you
under certain conditions, complete with data.

HTH,
Dan

- Show quoted text -

Quote
>Please help!!

>Regards
>Jaco van Niekerk

Re:Creating a database problem - please help!


Hi again.

Please look at this question again (down below).  It still doesn't make
sense.  If I step through the program it does *NOT* report any problems (no
exceptions are thrown).  The moment I go out of debugging mode it starts
throwing the EAccessViolations.  If I add a pause (a MessageDlg - just for
testing) after every Database1.Execute(...) it still throws the exceptions
?!?!?!?!?

Please help!!

"Dan" <DanB at CMDCsystems dot com> wrote in message
news:rdk7cvo7obauv1jhi5175j8nhcp0aet98k@4ax.com...

Quote
> On Thu, 15 May 2003 13:01:37 +0200, "Jaco van Niekerk"
> <spa...@lantic.net> wrote:

> >Hello all fellow coders

> >I just love it when queries and code start working and we all know that
the
> >satisfaction of achievement becomes a drug.  Sadly, my next "fix" keeps
> >avoiding me.  Please help!

> >I need to create a local Paradox database consisting of multiple tables
> >during run-time.  I prefer using SQL as I know it well and would like to
> >expand the system later on to be distributed.

> Using queries and SQL is the right way to go.

> >Currently, I am doing something like the following:

> >procedure TDBDataModule.CreateTables(Path: string);
> >var
> >  Tmp: string;
> >  ParamList : TParams;
> >begin
> >     ParamList := TParams.Create;
> >     DatabaseMake.DatabaseName := Path;
> >     DatabaseMake.Open;

> >     try
> >        Tmp := 'CREATE TABLE "client.db" .....) ';    // SQL left out to
> >save space
> >        DatabaseMake.Execute(Tmp, ParamList, False, nil);

> >        Tmp := 'CREATE TABLE "employee.db" .....) ';
> >        DatabaseMake.Execute(Tmp, ParamList, False, nil);

> >        ... (creating 8 more tables in a similar fashion)

> >     finally
> >           ParamList.Free;
> >     end;
> >end;

> >The problem with this is that I get an EAccessViolation (...read of
address
> >FFFFFFFF) which suggests a null pointer somewhere, but I don't understand
> >why.  The strangest thing however, is that sometimes the tables are
created,
> >and sometimes not.

> This error usually means you are trying to access some object which
> hasn't been created yet, or has already been destroyed. Use
> breakpoints to step through your code to find the statement which
> causes the AV. Good luck :-)

> >Perhaps there is a different way to create a set of tables run-time?
...or
> >am I missing something obvious above?

> If I am going to need a local table at runtime, I usually go ahead and
> make an empty one and have it there all the time. Another method is
> the BatchMove component. It will create the destination table for you
> under certain conditions, complete with data.

> HTH,
> Dan

> >Please help!!

> >Regards
> >Jaco van Niekerk

Re:Creating a database problem - please help!


That is strange. The next thing I would try is to delete all the .dcu
files from the project and recompile. This will force Delphi to
recompile everything, not just the units that have changed. This ofter
clears up strange behavior.

Dan

On Fri, 16 May 2003 03:53:39 +0200, "Jaco van Niekerk"

Quote
<spa...@lantic.net> wrote:
>Hi again.

>Please look at this question again (down below).  It still doesn't make
>sense.  If I step through the program it does *NOT* report any problems (no
>exceptions are thrown).  The moment I go out of debugging mode it starts
>throwing the EAccessViolations.  If I add a pause (a MessageDlg - just for
>testing) after every Database1.Execute(...) it still throws the exceptions
>?!?!?!?!?

>Please help!!

Other Threads