Link to home
Start Free TrialLog in
Avatar of darknighter
darknighter

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of _ys_
_ys_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marcomania
marcomania

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:
http://www.connectionstrings.com
http://www.able-consulting.com/ADO_Conn.htm
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;"
cnn.Open
Avatar of Éric Moreau
Avatar of darknighter

ASKER

emoreau, what is method for Access Database
Not execute, the code is obsolete
???

DSNs are obsolete! Is it working or not?
Did you try DSNless connection as I mentioned above?