Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread Local EXE - installing to different path
Thu, Jul 19 2007 9:54 PMPermanent Link

"Alan Questell"
I have had this problem before, but thought I had it solved.

I want to write the datamodule so that the EXE can install to a different
path (with a DATA subdirectory like the CDCollector) and it will run
correctly.

I thought I had this fixed following the CD Collector but it was only
working because the old directory before I moved the program was still
there.

I was using the CD Collector program as an example, but I find it doesn't
work either. If I compile it in one location and then copy the whole thing
(say from a jump drive to the desktop), CD Collector will not run correctly.
I thought it was, but pulling out the jump drive proves it was trying to
access the old files on the jump drive even though it has the routines of
setting the ConfigPath to the application path and creating the database.

I would like an example of how this is done if anyone has one...make the EXE
folder location (with a DATA subdirectory) location neutral (as was easily
done with DBISAM).

Fri, Jul 20 2007 2:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Alan


Are you copying the catalog as well? If so you'll need to DROP the database and create a new one with the new path.

Roy Lambert
Fri, Jul 20 2007 9:07 AMPermanent Link

Alan Questell
Yes, I drop the database and then add just as the CDCollector example program does. However, what I'm trying to say is that the CDCollector
doesn't do this correctly either.

To show this, put CDCollector folder in some location. Open it and compile it. Copy the folder to another location (I was going from a jump drive to
the hard drive). Run the CDCollector EXE from the new location and it will work at first. Go back and delete the old location folder (in my case, I was
just removing the jump drive) and try to run the CDCollector EXE and it will fail at startup trying to use the old location.





Roy Lambert <roy.lambert@skynet.co.uk> wrote:

Alan


Are you copying the catalog as well? If so you'll need to DROP the database and create a new one with the new path.

Roy Lambert
Fri, Jul 20 2007 9:26 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Alan


My copy of CD Collector doesn't contain the word DROP at all so I'm not sure what you're referring to Smiley

Roy Lambert
Fri, Jul 20 2007 10:40 AMPermanent Link

"Alan Questell"
You're right - it doesn't, so where would it go in that example?

CDCollector doesn't work as written if it is moved; it never gets to the
point where it creates the missing database. It fails before. There has to
be a way of starting from a different location.


"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:FF52653A-04B8-47E8-8BD6-0E012ABD473A@news.elevatesoft.com...
> Alan
>
>
> My copy of CD Collector doesn't contain the word DROP at all so I'm not
> sure what you're referring to Smiley
>
> Roy Lambert
>

Fri, Jul 20 2007 1:52 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Alan


As I said at the beginning DROP database, CREATE DATABASE PATH.....

If you don't then it will be using the database that's already been created. The new approach (ie directory <> database) takes a bit of getting used to. If you look at the CD Collector example what Tim does is check for the existence of the database, if its not there then create it. Remember its NOT checking for the existence of the directory simply for the existence of a record in the configuration databases table.

You could try the following (untested) code

  with ConfigurationQuery do
     begin
     SQL.Text:='SELECT * FROM Databases WHERE Name='+Engine.QuotedSQLStr('CDCollector');
     Open;
     if (RecordCount=0) then
        begin
        { Database doesn't exist and we need to create it }
        Close;
        SQL.Text:='CREATE DATABASE "CDCollector" PATH '+
                   Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data');
        ExecSQL;
        end
     else
     if AnsiCompareText(ConfigurationQuery.FieldByName('Path').AsString,ExtractFilePath(Application.ExeName)+'data') <> 0 then begin
       Close;
       SQL.Text:='DROP DATABASE "CDCollector" KEEP CONTENTS';
       ExexSQL;
       Close;
        SQL.Text:='CREATE DATABASE "CDCollector" PATH '+
                   Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data');
        ExecSQL;
     end else Close;
     end;

ie

If the database doesn't exist create it, if it does check the paths are the same and if not zap it and create.


Roy Lambert
Fri, Jul 20 2007 3:08 PMPermanent Link

"Alan Questell"
That appears to work as expected.

Thanks so much for your help.

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:1BD775EC-C010-482B-A051-5CCBA3081179@news.elevatesoft.com...
> Alan
>
>
> As I said at the beginning DROP database, CREATE DATABASE PATH.....
>
> If you don't then it will be using the database that's already been
> created. The new approach (ie directory <> database) takes a bit of
> getting used to. If you look at the CD Collector example what Tim does is
> check for the existence of the database, if its not there then create it.
> Remember its NOT checking for the existence of the directory simply for
> the existence of a record in the configuration databases table.

Fri, Jul 20 2007 3:48 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< If you don't then it will be using the database that's already been
created. The new approach (ie directory <> database) takes a bit of getting
used to. If you look at the CD Collector example what Tim does is check for
the existence of the database, if its not there then create it. Remember its
NOT checking for the existence of the directory simply for the existence of
a record in the configuration databases table. >>

Nice job, and nice example.  If this keeps up, I can just hire you and take
the next few weeks off. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Jul 21 2007 3:58 AMPermanent Link

"Tom"
I think "DROP DATABASE.." will delete all SPs or triggers/views for the
database.
You'll need altering database path but there's no such sql.(only altering
description of database)



"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:1BD775EC-C010-482B-A051-5CCBA3081179@news.elevatesoft.com...
> Alan
>
>
> As I said at the beginning DROP database, CREATE DATABASE PATH.....
>
> If you don't then it will be using the database that's already been
> created. The new approach (ie directory <> database) takes a bit of
> getting used to. If you look at the CD Collector example what Tim does is
> check for the existence of the database, if its not there then create it.
> Remember its NOT checking for the existence of the directory simply for
> the existence of a record in the configuration databases table.
>
> You could try the following (untested) code
>
>    with ConfigurationQuery do
>     ?begin
>     ?SQL.Text:='SELECT * FROM Databases WHERE
> Name='+Engine.QuotedSQLStr('CDCollector');
>     ?Open;
>     ?if (RecordCount=0) then
>          begin
>          { Database doesn't exist and we need to create it }
>          Close;
>          SQL.Text:='CREATE DATABASE "CDCollector" PATH '+
>                   ?Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data');
>          ExecSQL;
>          end
>     ?else
>     ?if
> AnsiCompareText(ConfigurationQuery.FieldByName('Path').AsString,ExtractFilePath(Application.ExeName)+'data')
> <> 0 then begin
>       ?Close;
> ????SQL.Text:='DROP DATABASE "CDCollector" KEEP CONTENTS';
> ????ExexSQL;
> ????Close;
>          SQL.Text:='CREATE DATABASE "CDCollector" PATH '+
>                   ?Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data');
>          ExecSQL;
>     ?end else Close;
>     ?end;
>
> ie
>
> If the database doesn't exist create it, if it does check the paths are
> the same and if not zap it and create.
>
>
> Roy Lambert
>

Sat, Jul 21 2007 5:04 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>Nice job, and nice example. If this keeps up, I can just hire you and take
>the next few weeks off. Smiley

1. I'm still asking questions myself
2. I'm not as polite or forbearing as you - how many customers would you like to lose?

Roy Lambert
Page 1 of 2Next Page »
Jump to Page:  1 2
Image