Access connection string (adp)

D

dragos

Good day to everybody!

I have an old question and maybe one of you could help me.

Every Access project has a connection string which is somehow written
in the apd file. When the apd is executed it tries to connect using
that connection string which however may be inadequate if multiple
servers are used. (I mean off course there are multiple servers with
the same database attached, but these servers are in different
networks. The structure of the database is the same everywhere).

To modify the connection string you have to edit data link fields. (Can
be accessed by clicking File->Connection). Off course is not a big deal
to write some piece of code that however replaces Microsoft's data link
dialog box, but this is not my issue. (can be usefull under some
circumstances)

I just want a way to start an Access project unconnected. That is all
that I want.

I read the published documentation and I can't solve that in any way
but I'm almost sure that can be done.

Thanks for reading this!
Dragos
 
S

Sylvain Lafontaine

Close the connection and then open it with a blank connection string:

application.CurrentProject.CloseConnection
application.CurrentProject.OpenConnection ""

Don't know what will happen if you try to do this with an ADE. Also, the
newsgroup for ADP is m.p.a.adp.sqlserver .
 
D

dragos

Dear Sylvain,

First of all, thanks for answering my question!

Yeah, I know that should work, but from here it is raising a brand new
question.
Can I detect somehow the exit of my ADP?
Just because I need to modify the connection string with a blank one,
when the user exit from my app.
I have 3 different ideas. Please tell me your opinion (probably it is a
better one :))

1. On my own login form I'll put a mutex using createmutex api
function.
Write a simple exe that monitors that mutex and when it is no longer
handled, just reopen the ADP (with getobject for example) and modify
the connection string according to your post and then release and quit.
Off course that exe will be launched from my login form if the user
successfully enters the password. That should work (I have not tried it
yet) but it seem to me a bit annoying. Plus that I have to make a
registry entry (because I don't know the path where my app is installed
at the client) to proper get the path of that ADP.

2. I have to make a hidden unbound form which is always open. Since it
is hidden I suppose (?) it will be automatically close at last by
Access, even on an ADE. Simply modify the connection string of the ADP
at OnClose event. I'll try this right know because is more simple, but
I'm not sure if the result is always predictable. I'll let you know.

3. The ugliest one.
Write a class, implement that method and declare an instance of the
class on every form. At each OnClose event call that method. (Obviously
has many disadvantages including the heap loading). Besides that, for
binded forms this is simply...a wrong hack.

Anyhow please let me know your opinion!
Cheers, Dragos.
PS: In the future I'll post ADP related to the proper space :).
Thanks!
 
D

dragos

Hi, the second method works but I'm still not sure if the hidden form
will always be close by the last when leaving the app. Can you tell me
that? I don't want to check on every form for existance of the hidden
one.

Thanks again!
 
S

Sylvain Lafontaine

Sorry, I don't know. I never used this, so I cannot tell you more about
this subject.
 
Top