Solved

What's the difference between Delphi 7 IDE parameters and outside of it?

Posted on 2011-03-20
23
729 Views
Last Modified: 2012-06-21
My application requires parameter to run standalone, otherwise it wont work. So, in order to debug it, I kind of need to insert those parameters (Run->Parameters). When the app starts, it creates a temporary database, however, when I start with F9, says the temporary database file could not be found, and if I start with ctrl+shift+f9 (outside of delphi), works fine.

I've been trying to grasp the difference between inside and outside of delphi ide, since the application wont run properly inside of it.

Thanks.
0
Comment
Question by:John86a
  • 13
  • 4
  • 2
  • +3
23 Comments
 
LVL 19

Expert Comment

by:Thommy
Comment Utility
Maybe the temporary database file is expected in the directory of the exe file!!!

Copy your temporary database file into your Delphi project dir to make sure that your app can find it...
0
 
LVL 2

Expert Comment

by:RezaSadigh
Comment Utility
Hi my friend,
Check the path or other thing that address your db. there is not any difference between IDE parameters and outside of it.
Best regards
0
 

Author Comment

by:John86a
Comment Utility
There isn't, the temporary database is created on c:\users\name\appdata\local\temp (on the temporary folder %temp%). Inside delphi IDE says it couldnt located the temporary database, whereas outside functions fine.
0
 

Author Comment

by:John86a
Comment Utility
Inside delphi IDE, it doesnt create the file, outside of it, does.
0
 
LVL 19

Expert Comment

by:Thommy
Comment Utility
Can you please provide the detailed error message???
0
 

Author Comment

by:John86a
Comment Utility
Project RF8.exe raised exception class EDBEngineError with message 'Table does not exist. Table: C:\User\John\AppData\Local\Temp\IjKPz.db'. Process stopped. Use Step or Run to continue.
0
 

Author Comment

by:John86a
Comment Utility
What's strange is that outside of IDE, works fine.
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
The is no difference, in terms of how it functions, except it's called from the IDE and the parameters are clearly passed. But outside the IDE you have to pass the parameters yourself.

How do you run your application outside the IDE (i.e. how do you pass the parameters to your application outside the IDE)?

Can you show the part of the code that handles the parameters?
The more information you provide the more easy it gets to find out what's going on.
0
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility

You need to think about why you need to create a database in the temporary folder to begin with.
What is this database used for?

Normaly when using temp data, the data location is not passed to the application through parameters, this is something your application needs to handle itself in your application startup or FormCreate of the main form. You request a folder and create your temporary data.

If the data is supposed to be persistent, then you put it in your exe path or give a relative path to your exe file or thirdly you can have an .ini or .cfg file which your application reads to discover the data path.

Handling the parameters at design and runtime are not any different from each other
0
 

Author Comment

by:John86a
Comment Utility
Outside of delphi:
Start->Run type: "C:\RFProjects\RF8.exe" ADMIN p/GKgORsxPc= MRETJ 1 1 65498 565632 87 32154 12 3932 5832 S S
Works absolutely fine.

Inside of delphi:
Doesn't work. Not because of parameters, because the error occur before it can read the parameters.

Error Message: Project RF8.exe raised exception class EDBEngineError with message 'Table does not exist. Table: C:\User\John\AppData\Local\Temp\IjKPz.db'. Process stopped. Use Step or Run to continue.

jimyX: I've separated the most important parts of the file, where the table is created/deleted and where the parameters are read. Although I think that the problem lies inside table creation/deletion, not parameters reading, since with or without parameters, it returns the same error inside delphi. The file is attached.

Inside the file I've made comments to what happens if I comment the error line.
problemdata.pas
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
That error means one thing which is the table you are deleting does not exist or the name is not correct (i.e. the db table may exist but the name does not match the name that was used in your application).

To avoid like this errors, check first if the table exists and closed:

  if (Table1.Exists) and (Table1.Active = False) then

Also let's place "ShowMessage(Table1.DatabaseName +' - '+ Table1.TableName);" before deleting the table. Before clicking OK ensure the table does exist in the location where you created it and the path appeared in the message:

So the Delete part in your code shall look like this:
procedure TTemp.Generate;
var
  i: Integer;
  xError: boolean;
begin
...
  try
    ShowMessage(tblr.DatabaseName +' - '+ tblr.TableName);
    if (tblr.Exists) and (tblr.Active = False) then
      tblr.DeleteTable
    else
      ShowMessage(tblr.TableName +' does not exist');    
  except
  end;
...

Open in new window

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:John86a
Comment Utility
Hmmm, how curious, I introduced your code exactly how you showed it.

When I ran the program it showed: 'C:\Users\John\AppData\Local\Temp\ - db80C9.db' on the showmessage, and then another showmessage said 'db80C9.db does not exist'. By clicking OK I verified on C:\Users\John\AppData\Local\Temp\ that the file had been created (sorting by Date modified). However, delphi halted with the error I stated on a comment in the file I attached.

Error: Project RF8.exe raised exception class EDatabaseError with message 'Invalid alias name C:\Users\John\AppData\Local\Temp\'. Process stopped. Use Step or Run to continue.

Accusing this exact line:
if Session.GetAliasDriverName(aDatabaseName) = TMPORACLE then

Bugs me that it functions fine without delphi.
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
Comment Utility
I do not know what you pass in the parameter "aDatabaseName" but as per the message "INVALID ALIAS NAME 'C:\User\...", you did pass the DatabaseName property (I presume) as a parameter. If so, you can't pass that as an Alias.
The alias is, as per Delphi help:
AliasName specifies the Borland Database Engine (BDE) alias used by this database connection.

So to get the Alias of your Table (If that what you are doing then pass the Database.AliasName to the procedure "ChangeFieldDefsToOracle":

Table1.Database.AliasName

To get all the AliasNames use this code:
procedure TForm1.Button1Click(Sender: TObject);
var
  Str : TStrings;
begin
  Str := TStringlist.Create;
  Session.GetAliasNames(Str);
  showmessage(Str.Text);
  if assigned(Table1.Database) then
    ShowMessage(Session.GetAliasDriverName(table1.Database.AliasName));
  Str.Free;
end;

Open in new window



>   "When I ran the program it showed: 'C:\Users... - db80C9.db' on the showmessage, and then another showmessage said 'db80C9.db does not exist'."

May be the table is Active. Try this please:
procedure TTemp.Generate;
var
  i: Integer;
  xError: boolean;
begin
...
  try
    ShowMessage(tblr.DatabaseName +' - '+ tblr.TableName);
    if tblr.Exists then
      if tblr.Active then
        ShowMessage(tblr.TableName +' is Active')
      else
        begin
          tblr.DeleteTable;
          Showmessage('Deleted');
        end;
    else
      ShowMessage(tblr.TableName +' does not exist');    
  except
  end;
...

Open in new window

0
 
LVL 14

Expert Comment

by:systan
Comment Utility
hi
did jimyX solution solved the problem?
if not?,
try to ran delphi in administrator account, then ran the code.
because I think it's an account security issue.
0
 
LVL 14

Expert Comment

by:systan
Comment Utility
And I think your operating system is windows 7.
Running Delphi 7 below version 7.3.3.4or5 would error some compilations.
Even installation in Windows 7 with Delphi 7.3.3.4or5 below is not good.
0
 

Author Comment

by:John86a
Comment Utility
With the new code this is exactly what happens:
I press F9
ShowMessage1: C:\Users\John\AppData\Local\Temp\ - db61E6.db
ShowMessage2: db61E6.db does not exist
Opens Program
Two to Three seconds later
ShowMessage3: C:\Users\John\AppData\Local\Temp\ - dbEF47.db
ShowMessage4: dbEF47.db does not exist

Debugger Exception Notification: Project RF8.exe raised exception class EDatabaseError with message 'Invalid alias name C:\Users\John\AppData\Local\Temp\'. Process stopped. Use Step or Run to continue.
Points to that line I told you "if session.."

Here's the part where ChangeFieldDefsToOracle is used:
usageofChangefielddefs.pas
0
 

Author Comment

by:John86a
Comment Utility
I'm using Windows 7 64 bits, yes.
With this release of delphi:
Delphi7 Lite Edition 7.3.4.1 [2011-01-01] [All Updates Integrated][Optional D2007 RTL/VCL][Portable-Edition Integrated][Supports Windows7 Fully]
0
 

Author Comment

by:John86a
Comment Utility
Also tried to run delphi as administrator, since this was the first thought that cross my mind :(
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
Just to confirm, did you adjust your code as per my post #35175973?

I see you are still using DatabaseName, use table1.Database.AliasName instead.
0
 

Author Comment

by:John86a
Comment Utility
I wasn't able to run your code, says:
Incompatible types: 'String' and 'TStringList'
Incompatible types: 'TStrings' and 'String'
Record, object or class type required
etc,

But I know the alias name in BDE, is that the same alias name its retrieving?
0
 

Author Comment

by:John86a
Comment Utility
also, where exactly do I introduce the alias name as you specified ?
I've attached the procedure ChangeFieldDefsToOracle.
0
 

Author Comment

by:John86a
Comment Utility
PS.: if I introduce it to the usage of changefielddefs as (database.aliasname, self)
Compiles, but says it wasn't able to load stuff from the database.
If I change to (databaseName.aliasname,self) - being that databasename is the used one now, I get:
Record, object or class type required

0
 

Author Closing Comment

by:John86a
Comment Utility
Thanks, I was able to make it work by forcing in the name of the alias! Just don't understand why it wasn't getting it.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now