how can i create a DSN in runtime

i'm work win a access 2000 db, and  i just want to create the DSN with code, but before use de code i want con ask if the DSN exist, if the code exist i just use it, if it don't exist i create it  

i'm developing an aplication that use Crytal Report 8.5, it suppouse that the user can install this aplication in any folder; therefore the aplication should detect the data sources that will use the crytal report
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Check under the registry key
for the dsn you're expecting to see - it'll be a string value - the value will be "Microsoft Access Driver (*.mdb)".

If it's not there create that string value, and also the following entries
"{your_dsn_name}"="Microsoft Access Driver (*.mdb)"

Also add the following to define your dsn.
"FIL"="MS Access;"


I'm sure there's gotta be an easier way, but this is a method I've used before.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Did you already tried it without this check?
As far as I know, if the DSN doesn't exists it is created automatically.
Why not use a DSNless connection. All you have to do is create a connection string and open the connection object at runtime. In connection string you will pass all required parameters like data source name and username, passord etc. Here are two sites where you can find connection string for various databases:
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Here is an example:

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\My Documents\myDatabase.mdb;"
Éric MoreauSenior .Net ConsultantCommented:
darknighterAuthor Commented:
emoreau, what is method for Access Database
Éric MoreauSenior .Net ConsultantCommented:
darknighterAuthor Commented:
Not execute, the code is obsolete
Éric MoreauSenior .Net ConsultantCommented:

DSNs are obsolete! Is it working or not?
Did you try DSNless connection as I mentioned above?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.