?
Solved

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

Posted on 2011-03-20
23
Medium Priority
?
746 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 4
  • 2
  • +3
23 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 35175142
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
ID: 35175145
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
ID: 35175155
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

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

Expert Comment

by:Thommy
ID: 35175236
Can you please provide the detailed error message???
0
 

Author Comment

by:John86a
ID: 35175256
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
ID: 35175263
What's strange is that outside of IDE, works fine.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35175392
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:Ephraim Wangoya
ID: 35175579

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
ID: 35175670
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
ID: 35175840
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
 

Author Comment

by:John86a
ID: 35175889
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 2000 total points
ID: 35175973
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
ID: 35176076
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
ID: 35176125
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
ID: 35176181
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
ID: 35176194
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
ID: 35176198
Also tried to run delphi as administrator, since this was the first thought that cross my mind :(
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35176451
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
ID: 35176703
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
ID: 35176711
also, where exactly do I introduce the alias name as you specified ?
I've attached the procedure ChangeFieldDefsToOracle.
0
 

Author Comment

by:John86a
ID: 35176759
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
ID: 35178008
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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.
Suggested Courses

765 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