To quickly establish a database connection from ASP, try using a file DSN. The DSN string should not contain spaces, either, before or after the equal sign (=). In this case, the recordset object's Open method refers to the file based DSN, containing location and configuration information about the database. Remember to create the file DSN before using it in the code. Another option is to refer directly to an explicit provider, data source, user ID, and password, rather than to a DSN.
An example to access a database from ASP using file DSN is shown below (remember to put the code in <% and %>):
' Create connection object
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "FILEDSN=TestWeb.dsn"
strSQL = "select FirstName,LastName FROM person"
'Instantiate a Recordset object
Set rsResults = Server.CreateObject("ADODB.Recordset")
rsResults.Open strSQL, cn
Set objFirstName = rsResults("FirstName")
Set objLastName = rsResults("LastName")
Do Until rsResults.EOF
Response.Write objFirstName & " " & objLastName & "<BR>"
rsResults.MoveNext
Loop
' Clean up is a good practice
cn.Close
Set rsResults = nothing
Set cn = nothing