Making a DSN-Less connection can be very tricky for newbies to ASP. This is done
by telling the server to use a file instead of a DSN name
To setup a DSN-Less connection on DomainDLX, use the following code:
<%Dim Conn, RS
Set Conn =
Server.CreateObject("ADODB.Connection")
Set RS =
Server.CreateObject("ADODB.Recordset")
DSNName = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
DSNName = DSNName & Server.MapPath("/USERNAME/database/mydatabase.mdb")
Conn.Open DSNName
sql = "SELECT * FROM [TableName] WHERE (((TableName.FieldName)='Value'))"
RS.Open sql, Conn, 3, 3%>
The first line tells the server to set aside memory for new objects called Conn and RS
The next two lines tells the server to create a ADODB Connection and RecordSet object
under the names Conn and RS.
The next three tell the server to make a connection to a Microsoft Access database in
the file named /USERNAME/database/mydatabase.mdb. The
Server.MapPath is so that the filename as the server knows it on it's hard drive can be
given to this script. You must refer to it this way.
The SQL line selects the table to get records from, by the SELECT * FROM [TableName].
The WHERE will tell the server to only show records matching a special rule.
There are more complex rules than the ones I show here. This rule tells the server
to show only records where the field FieldName equals the string
"Value". Remove WHERE and all text after it to use the entire table.
And, the last line opens and queries the SQL statement. The two parameters with
the value of 3 will set the table-locking, so you can write to the database but not keep people from
viewing it while you do so.
By: Matthew Holder