Solved

Using DSN or DSN Less Connections for Database Connectivity

Posted on 2001-06-24
3
263 Views
Last Modified: 2010-05-02
Using DSN or DSN Less Connections for Database Connectivity in VB or ASP?

Can anyone give me a answer for the above?


Thank You

Anil Mahadev
0
Comment
Question by:ecomguru2000
3 Comments
 
LVL 15

Expert Comment

by:robbert
ID: 6222812
Mostly, DSN-less connections are used, basically, because they don't have to be set up.

Here are examples of DSN-less connection strings:
http://www.able-consulting.com/ADO_Conn.htm

If there are further questions let me know.
0
 
LVL 6

Accepted Solution

by:
kahlean earned 100 total points
ID: 6223069
DSN less connection are useful if your application is going to be on mutliple systems and the server information might change from location to location. By using a DSNless connection, you can store the data connection informatin in a file that is read each time the application start. If the information needs change, simply change the file information rather than distributing a new DSN. DSN-less connection are especially useful for web application because they allow you to move the application from one server to another without recreating the DSN on the server.


Here is a dsnless connection example.

'********************************************************

Public Function DSNless () AS Boolean

Dim cn AS New ADODB Connection
Dim sConn As String


On Error GoTo Err

DSNless = False

sConn = "Driver={Microsoft Access Driver (*.mdb)};" _
     & "DBQ=C:\dbName.mdb;" _
     & "UID=Admin;PWD='';"

cn.Open sConn
Debug.Print cn.ConnectionString
DSNless = True
Exit Function


Err
   MsgBox "Error in database connectivity"
   Exit Function
End Function

'******************************************************
On the other hand a DSN connection stores the information in a file that can be read by any application. THis make an application more easily portable between computer becauser only the file needs to be move rather than having an installation progam set ip a DSN on the target system. A DSN can be set via ODBC Data Source in your control panel. Here is a sample of a DSN connection

'********************************************************
Public Function DSNcon () AS Boolean

Dim cn AS New ADODB Connection

On Error GoTo Err

DSNcon = False

cn.Open "dsnDatabase"

Debug.Print cn.ConnectionString
DSNcon = True
Exit Function

Err
   MsgBox "Error in database connectivity"
   Exit Function

End Function

'*****************************************************





0
 
LVL 2

Expert Comment

by:TravisHall
ID: 6223202
Quoth kahlean, "DSN less connection are useful if your application is going to be on mutliple systems and the server information might change from location to location. By using a DSNless connection, you can store the data connection informatin in a file that is read each time the application start. If the information needs change, simply change the file information rather than distributing a new DSN."

Actually, if this is your concern, your best option is generally to use a File DSN, rather than going completely DSN-less. That way, you can still use the handy tools that create DSNs, and you have the advantage of having your app read what it needs from a file stored on your server.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

13 Experts available now in Live!

Get 1:1 Help Now