Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADOConnection => Select a database

113 views
Skip to first unread message

Christian Ista

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to
Hi,

At design time I gave to the property ConnectionString some information and
the full path for the Access file.....

But, at desgin time, I gave for example C:\MyDatabase\MyDatabase.mdb. It's
possible than the database is not is this directory on the others computers.

How can I do for give the right path ? I'l like give tha path and after
that activate the ADOConnection in the Main form OnActivate event ...

Bye

--
------------
French Mailing List Visual C++ and Borland C++ Builder
French Mailing List Flash on my web site
----- Christian Ista's Softs http://www.IstaSofts.com
----- Christian Ista (Liege-Belgium) on IRC Boubou, ^Boubou^,...
----- Christi...@bigfoot.com ou Ista...@bigfoot.Com


Christian Ista

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to

Bill Todd (TeamB)

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to
I guess I do not understand the question. If you want to change the path
just change the path in the ConnectionString property. Another approach is
to use a UDL file and create the file with the correct path as part of your
installation process. UDL's are just text files. To create one as a sample
right click in explorer, choose new, then choose Microsoft Data Link.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Christian Ista

unread,
Feb 26, 2000, 3:00:00 AM2/26/00
to

> I guess I do not understand the question. If you want to change the path
> just change the path in the ConnectionString property.

Yes at desgin time. But If I want to install my software on an another PC,
the database is may be at the same place...


> Another approach is
> to use a UDL file and create the file with the correct path as part of
your
> installation process. UDL's are just text files.

How to put the content of this text file in the ConnectionString Property ?

> To create one as a sample
> right click in explorer, choose new, then choose Microsoft Data Link

I tried wih windows 95 (DCOM + MDAC 2.1), I can see this option in the
popmenu (right click) but not wiht windwos NT + SP 6 + MDAC 2.5

Bye

Bill Todd (TeamB)

unread,
Feb 26, 2000, 3:00:00 AM2/26/00
to
The ConnectionString property is of type WideString. Since it is just a
string you can change it as you would any other string property at runtime.
For example, the connection string to use the DBDemos UDL file that comes
with Delphi is:

FILE NAME=C:\Program Files\Common Files\System\ole db\Data Links\DBDEMOS.udl

If I want to change the string in code I could do something like

ADOConnection1.ConnectionString := 'FILE NAME=' +
ChangeFileExt(Application.ExeName, '.udl');

to set the connection string to a UDL file that has the same name as my EXE
and is in the same directory as my EXE. If you do not want to use a UDL file
create a connection string at design time using the property editor then
copy the connection string to Notepad or the code editor so it is easy to
see the whole string. Somewhere in the string you will find the path to the
database. All you have to do is write code to change that part of the string
at runtime.

If this does not answer your questions please explain what it is that you do
not understand and I will try to help.

Christian Ista

unread,
Feb 28, 2000, 3:00:00 AM2/28/00
to

> ADOConnection1.ConnectionString := 'FILE NAME=' +
> ChangeFileExt(Application.ExeName, '.udl');

Hello Bill and the other,


I did, in OnActivate (MainForm) ....

1. Close all the tables
2. Disconnect the ADOConnection
3. ADOConnection1.ConnectionString := 'FILE NAME=' +
ChangeFileExt(Application.ExeName, '.udl');
4. Connect ADOConnection


and at this moment, I receive this message .... "The file %1 is not a valid
compound file" ....

If I do only the point 3 I receive this message "Operation is not allowed
when the object is open", it's normal I think...

Bye

Bill Todd (TeamB)

unread,
Feb 28, 2000, 3:00:00 AM2/28/00
to
Did you create and test the UDL file first?

cmpe...@hotmail.com

unread,
Feb 29, 2000, 3:00:00 AM2/29/00
to

> 1. Close all the tables
> 2. Disconnect the ADOConnection
> 3. ADOConnection1.ConnectionString := 'FILE NAME=' +
> ChangeFileExt(Application.ExeName, '.udl');
> 4. Connect ADOConnection

try
3. ADOConnection1.ConnectionString := 'FILE NAME=' + ExtractFilePath
(Apllication.ExeName) + '\MyConn.udl';

Works for me.

--
cmpe...@hotmail.com
Home Of ReefCon 2K - Aquarium Maintainence,
Reference, Logging, and Control software
http://www.cmpenney.com


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages