This article contains the following sections:
- Activating and using MS Access DSN
- Activating and using Microsoft SQL Server DSN
- DSN-less Connections
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
- 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.
- Sign in to SiteControl.
- Go to Manage Services tab.
- Go to Website section.
- 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.
- On DSN (Data Source Name) Overview page, select the proper domain name from the Currently Managing drop-down menu.
- Click the Activate button in the Activate Access DSN box.
- 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).
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. - Click Create DSN.
- A Request(s) Successfully Received message appears.
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" %> |
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
- 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.
- Sign in to SiteControl.
- Go to Manage Services tab.
- Go to Website section.
- 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.
- On DSN (Data Source Name) Overview page, select the proper domain name from the Currently Managing drop-down menu.
- Click the Activate button in the MS SQL DSN box.
- Now enter the name you wish to use for the DSN and select its corresponding MS SQL database.
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. - Click Create DSN.
- A Request(s) Successfully Received message appears.
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" %> |
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 " %> |