Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating a permanent Alias in IDAPI32.CFG file

Posted on 2007-11-15
3
Medium Priority
?
551 Views
Last Modified: 2010-04-21
Hi Experts,
I'm trying to add a new Alias to the IDAPI32.CFG file, which I want to stay permanently. i.e.

  Check(DbiAddAlias(nil, PChar(AliasName), nil, PChar(AliasPath), True));

The problem is the new Alias only remains in the IDAPI32.CFG file for the current session.  On closing the session the new Alias is deleted!

Many thanks
0
Comment
Question by:Vector7
[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
3 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 2000 total points
ID: 20293958
This is how I do it.

First make sure you have added DBTables to your unit's uses clause.

Then in a procedure such as a OnButtonClick:

Let me know if it works :)

var
sNewAlias, sDataDir :string;
mystringlist : TStringlist;
daindex : integer;
begin
mystringlist := TStringlist.Create;
 
//Assign name of the Alias to a string
sNewAlias := 'MyNewAlias';
//Assign name of the Alias's data directory to a string
sDataDir := Edit1.text;
//In the current session, grab the names of all the aliases and store them in myStringList
session.GetAliasNames(mystringlist);
//Get the index of your desired new alias - if it already exists you'll get a number > -1, else you'll get -1
daIndex := mystringlist.IndexOf('MyNewAlias);
 
//If the Alias already exists, delete it
if daIndex <> -1 then
Session.DeleteAlias('MyNewAlias');
 
//Now add the new alias, note the last section will create a 'PARADOX' database alias.
Session.AddStandardAlias(sNewAlias, sDataDir, 'PARADOX') ;
 
//And here's your magic line: SAVE THE CFG FILE!
Session.SaveConfigFile;
 
end;

Open in new window

0
 
LVL 10

Expert Comment

by:dinilud
ID: 20296453
 procedure ChangeAliasDirPARADOX(Alias, Dir: String);
  begin
    if DirectoryExists(Dir) then
    begin
      if Session.IsAlias(Alias) then  Session.DeleteAlias(Alias);
      Session.AddStandardAlias(Alias, Dir, 'PARADOX');
      Session.SaveConfigFile;
    end;
  end;
0
 

Author Closing Comment

by:Vector7
ID: 31409439
Works well. Many thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

704 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