Solved

Using DSN or DSN Less Connections for Database Connectivity

Posted on 2001-06-24
3
264 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

18 Experts available now in Live!

Get 1:1 Help Now