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

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.
John86aAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
jimyXConnect With a Mentor Commented:
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
 
ThommyCommented:
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
 
RezaSadighCommented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
Inside delphi IDE, it doesnt create the file, outside of it, does.
0
 
ThommyCommented:
Can you please provide the detailed error message???
0
 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
What's strange is that outside of IDE, works fine.
0
 
jimyXCommented:
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
 
Ephraim WangoyaCommented:

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
 
John86aAuthor Commented:
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
 
jimyXCommented:
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
 
John86aAuthor Commented:
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
 
systanCommented:
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
 
systanCommented:
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
 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
Also tried to run delphi as administrator, since this was the first thought that cross my mind :(
0
 
jimyXCommented:
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
 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
also, where exactly do I introduce the alias name as you specified ?
I've attached the procedure ChangeFieldDefsToOracle.
0
 
John86aAuthor Commented:
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
 
John86aAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.