Solved

specifing a path for a database alias

Posted on 2000-05-11
4
289 Views
Last Modified: 2012-05-04
Thankyou for your answer.
I am using Delphi pro 5.
I have created an alias to an Access database using the driver MSACCESS. It presently has a fixed path to a directory on the C drive.
How can I specify a varying path so that the user can choose where they would like to install the database and other files.
For example they may wish to put the database on their D drive.
Thankyou,
Ivan
0
Comment
Question by:icarey
[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
4 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2799831
It's easy just look at this Delphi topic.

--------- TSession ------
Adds or changes parameters for a Borland Database Engine (BDE) alias.

procedure ModifyAlias(Name: String; List: TStrings);

Description

Call ModifyAlias to change the parameters for a specified BDE alias. Name is the name of the alias to modify. List is a string list object previously populated with parameter values to add or change. An application must create and maintain List.

Populate List with parameter strings before calling ModifyAlias. List need only contain the parameters to change. If ModifyAlias passes a parameter for which a value already exists, the new parameter replaces the existing one. New parameters that are not yet defined for the alias are added to the existing parameters. If List is empty, ModifyAlias does not change any existing parameters.
--------


There is a sample how to change alias path.

----
Igor
0
 
LVL 2

Accepted Solution

by:
IPCH earned 100 total points
ID: 2824772
If you want sample:

var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
    MyList.Add('TYPE=MSACCESS');
    MyList.Add('DATABASE NAME=:E:\Data\Stam.MDB');
    If Session.IsAlias('Ivan')
    Then Session.ModifyAlias('Ivan', MyList)
    Else Session.AddAlias('Ivan', 'MSACCESS', MyList);
  finally
    MyList.Free;
  end;
end.

Regards
Ivan
0
 
LVL 4

Expert Comment

by:Radler
ID: 2835377
Hi icarey,

My contribuition:

Because historical reason I don't use access, but the engine is seemless.
If want make use of Transactions( today is very frequent ) you'll need a TDatabase at you DataModule.
Using a TDabase to manager your Dataset's make you app more realible.
So put a TDatabase and give it a DatabaseName like "icarey_fly_alias"
set all Dataset to use this new alias and your datamodule create code put

TDatabase1.Connected:=False; //dataset must be closed here
TDatabase1.Directory:="MyTablesDirectory";
TDatabase1.Connected:=True;
//Open you dataset's here
.....

T++, Radler.
0
 
LVL 3

Author Comment

by:icarey
ID: 2843923
Answer accepted
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 184
Dev Express grid collapse 2 47
creating threads in delphi 1 163
Multi-layered image in FireMonkey 9 67
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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