Solved

specifing a path for a database alias

Posted on 2000-05-11
4
281 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now