DSN Connections

This article contains the following sections:

 

Definition of DSN

A Data Source Name (DSN) is a simple method of connecting to databases. A DSN contains the information about a specific database that an Open Database Connectivity (ODBC) driver needs in order to connect to it.

The data included in the DSN consists of:

  • Database name
  • Directory of the database
  • Driver of the database
  • ID and password of the user (depending on the type of DSN used).

ODBC, an open standard API for accessing databases, handles SQL requests and converts them into requests that the individual database systems understands. DSNs are also used by applications and Active Server Pages (ASP) to query databases and retrieve information.

 


 

Activate Access DSN

To order a DSN connection for your Access or FoxPro database, you will need to specify a name for the DSN connection and the name of the database. Depending on your Windows hosting plan, there may or may not be a charge. The DSN and database names must be between 2 and 14 characters and can contain only lowercase letters, numbers and hyphens.

 

To order a Microsoft Access DSN

  1. Prior to creating a DSN, you must first upload the appropriate Access database file to the server. For instructions, please click here. Once a database is uploaded, then proceed to Step 2.
  2. Sign in to SiteControl.
  3. Go to Manage Services tab.
  4. Go to Website section.
  5. Scroll down, find and click the DSN (Data Source Name) link. You can also click DSN (Data Source Name) in the left navigation panel in SiteControl.
    dsn-115000435010-1.png

  6. On DSN (Data Source Name) Overview page, select the proper domain name from the Currently Managing drop-down menu.
  7. Click the Activate button in the Activate Access DSN box.
    dsn-115000435010-2.png

  8. Now enter the name you wish to use for the DSN and select its corresponding Access database (that you already uploaded in Step 1 above).
    dsn-115000435010-3.png

    Depending on your hosting plan, there may or may not be a charge for Access DSN. Please refer to your plan details for further information. If there is a charge, you will be asked to confirm the charge after clicking on the Purchase button.

  9. Click Create DSN.
  10. A Request(s) Successfully Received message appears.
    dsn-115000435010-4.PNG

 

Using DSN connections

You may need this information when you connect to your database using a DSN connection.

Microsoft Access DSN connection strings
Without a password
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSNname"
%>
With a password
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSNname","username","password"
%>

 

BACK TO TOP


 

Activate Microsoft SQL Server DSN

To add a DSN connection, you will specify the name of the DSN connection as well as the database name. The DSN and database names must be between 2 and 14 characters and can contain only lowercase letters, numbers and dashes ( - ).

 

To order a Microsoft SQL DSN

  1. Prior to creating a DSN, you must first order a MS SQL database. For instructions, please click here. Once a database is created, then proceed to Step 2.
  2. Sign in to SiteControl.
  3. Go to Manage Services tab.
  4. Go to Website section.
  5. Scroll down, find and click the DSN (Data Source Name) link. You can also click DSN (Data Source Name) in the left navigation panel in SiteControl.
    dsn-115000435010-1.png

  6. On DSN (Data Source Name) Overview page, select the proper domain name from the Currently Managing drop-down menu.
  7. Click the Activate button in the MS SQL DSN box.
    dsn-115000435010-5.png

  8. Now enter the name you wish to use for the DSN and select its corresponding MS SQL database.
    dsn-115000435010-6.png

    Depending on your hosting plan, there may or may not be a charge for MS SQL DSN. Please refer to your plan details for further information. If there is a charge, you will be asked to confirm the charge after clicking on the Purchase button.

  9. Click Create DSN.
  10. A Request(s) Successfully Received message appears.
    dsn-115000435010-7.png

 

Using DSN connections

You may need this information when you connect to your database using a DSN connection.

Microsoft SQL Server DNS connection string
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSN=MyDSN;UID=user;PWD=password;DATABASE=mydatabase"
%>

 

BACK TO TOP


 

DSN-less Connections

A DSN-less connection is a method of connecting to a database without specifying a named data source. DSN-less connections don't require the creation of an ODBC DSN. Instead of relying on information stored in a file or in the system registry (as DSN connections do), DSN-less connections specify the driver name and all driver-specific information in the connection string.

Because a DSN-less connection is essentially "hard-coded" to use a certain driver, user identity and database location, problems may arise when database parameters change. Because the variety of connection parameters can differ greatly from one ODBC data source drive to another, it is recommended that you use a DSN whenever possible.

 

Microsoft Access DSN-less connection strings
Without a password
<%
Set Cnn = Server.CreateObject("ADODB.Connection")
strConAccess = "Driver={Microsoft Access Driver (*.mdb)};
DBQ=D:\wwwroot\domain.com\database\database.mdb"
Cnn.open StrConAccess
%>

With a password
<%
Set Cnn = Server.CreateObject("ADODB.Connection")
strConAccess = "Driver={Microsoft Access Driver (*.mdb)};
DBQ=D:\wwwroot\domain.com\database\database.mdb; Password=YourDBPassword"
Cnn.open StrConAccess
%>

OLE DB connection
<% Set Cnn = Server.CreateObject("ADODB.Connection")
strConAccess = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA
SOURCE=D:\wwwroot\domain.com\database\database.mdb"
Cnn.open strConAccess
%>

 

Microsoft Visual FoxPro DSN-less connection string
<%
Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr= "Driver=Microsoft Visual Foxpro Driver;
UID=userID;SourceType=DBC;SourceDB=D:\wwwroot\mydatabase.dbc"
Conn.Open ConnStr
%>

 

Microsoft SQL Server DSN-less connection strings
With a password
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={SQL
Server};SERVER=mssql.domain.com;UID=USER;PWD=password;DATABASE=mydatabase"
Conn.open DSNtest
%>

OLE DB connection
<% Set cnn = Server.CreateObject("ADODB.Connection") cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=mssql.domain.com;UID=username;PWD=password;DATABASE=mydatabase " %>

 

BACK TO TOP


 

Was this article helpful?
0 out of 0 found this helpful

Have more questions? Contact our support instantly via Live Chat