Solved

specifing a path for a database alias

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

12 Experts available now in Live!

Get 1:1 Help Now