<%@ LANGUAGE=VBSCRIPT%> Create a DSN-Less Database Connection <% ON ERROR RESUME NEXT Dim sConnection if not isnull(Request("Provider")) then ' Build the Connection String SELECT Case Request("Provider") CASE "Microsoft Access" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";User ID=" & Request("UserName") & ";Password=" & Request("Password") & ";" CASE "Microsoft Excel 95" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Excel 5.0;" CASE "Microsoft Excel 97" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Excel 97;" CASE "Microsoft Excel 2000" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Excel 8.0;" CASE "DBase III" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=dBASE III;" CASE "DBase IV" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=dBASE IV;" CASE "DBase 5" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=dBASE 5.0;" ' Will leave for later CASE "Microsoft FoxPro" sConnection = "" CASE "Paradox 3.x" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Paradox 3.x;" CASE "Paradox 4.x" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Paradox 4.x;" CASE "Paradox 5.x" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & "\" & Request("Location") sConnection = sConnection & ";Extended Properties=Paradox 5.x;" CASE "Microsoft SQL Server" sConnection = "Provider=SQLOLEDB.1; Network Library=dbmssocn;" sConnection = sConnection & "Password=" & Request("Password") sConnection = sConnection & ";User ID=" & Request("UserName") sConnection = sConnection & ";Initial Catalog=" & Request("DBName") sConnection = sConnection & ";Data Source=" & Request("SQLServer") & ";" CASE "Text" sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" sConnection = sConnection & "Data Source=D:\" & Request("IPAddress") & Request("Location") sConnection = sConnection & ";Extended Properties=Text;" CASE Else sConnection = "" END SELECT end if %>
<%if len(sConnection) > 0 then%> <%else%> <%end if%>

Creating a DSN-less Connection to a Datasource.

Below is your DSN-Less Connection to the Database you Specified. You should be able to Cut and Paste this into your code and test the connection to your Database.

 
Database Connection:
 

Active Server Page Code Example
 
--- BEGIN CODE COPY HERE ---->
<%@ Language=VBScript %>
<%
' Dim the Recordset Object
Dim rsADO

' Define the Connection String From Above
ConnectionString = "<%=sConnection%>"

' Create the Object
Set rsADO = Server.CreateObject("ADODB.Recordset")

' Define the SQL Statement
' (REPLACE TABLENAME WITH THE TABLE NAME
' IN YOUR DATABASE)
Source = "SELECT * FROM TABLENAME"
	
' Open the Recordset 
rsADO.Open Source, ConnectionString

' Display the Fields Returned 
' (PUT YOUR FIELD NAMES WHERE FieldName1 and 
' FieldName2 Appear)
if not rsADO.EOF then
	Response.Write rsADO("FieldName1") 
	Response.Write rsADO("FieldName2") 
end if

' DeAllocate the Object to Free Server Memory
set rsADO = nothing
%>
<--- END CODE COPY HERE ----
 

Create another DSN-LESS Connection
 

Creating a DSN-less Connection to a Datasource.

Please fill out all of the Information and Click on Generate.

Choose your Database Type:
Your Site's IP Address
Database Location (Relative - Non SQL)
SQL Server Name (SQL Only)
Database Name (SQL Only)
User Name
Password

 
** For more information about creating a DSN-Less Connection String using OLEDB 4.0 use the following link.
Microsoft Technical Article - Opening a Database (OLEDB 4.0)



Fields

Choose Your Data Type-This field is for selecting the type of database you are connecting to. Selecting the correct type is imperative.

Your Site's IP Address-Enter the Web IP of the customer's site

Database Location (Not Needed if SQL)-This field is for typing the location of the file on your site.
Be sure to type in the full path name, including sub directories, off your root directory.
Example: d:/IP Address/start database location here
If customer's database is in a databases directory and the database is contacts.mdb, you would type in databases/contacts.mdb in the field box.


SQL Server Name (SQL Only)-Enter the IP Address of the SQL server that the customer's database is on.

Database Name (SQL Only)-Enter the Database Name of the Customer's SQL database that you want to connect to

User Name-Enter the user name for the database that you are connecting to (Not needed if database is not password protected)

Password-Enter the password for the database that you are connecting to (Not needed if database is not password protected)