I've gotten a few questions lately asking about DSN-less connections and how to do them in ASP. For starters, DSN stands for Data Source Name, which was a configuration setting you had to make using ODBC. Each DSN defined how to get to the database, server names, etc. When you made a connection using DAO or RDO, you could specify a DSN.
However, building DSNs are tedious and a pain, especially if you don't have easy access to the ODBC applet on the machine. ADO doesn't require the use of a DSN. Instead, you can build the connection string by hand, as shown here:
Function OpenDB()
Dim dcnDB ' As ADODB.Connection
Set dcnDB = Server.CreateObject("ADODB.Connection")
dcnDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Data Source=D:\Files\Forums.mdb;"
dcnDB.Open
Set OpenDB = dcnDB
End Function
This function creates a DSN-less connection to an Access 97 database, opens it, and returns the database connection object to the caller. You can make all the DSN-less connections you need and never have to touch the server console. In addition, if you move this file to another machine, you don't have to worry about setting up the DSN on that machine. One concern you might have is in putting the user ID and password directly in your ASP file. An alternative is to store the user ID and password in another file somewhere else on your server. You open the file and read the user ID/password information and use it in the ASP file. Make sure that file is not in your web directory and make sure the web user has permission to access that file.