|
Answer
by: George Kaloyanov, Aplus.Net Knowledge Base Support.
With
Aplus.Net’s Windows 2003 hosting server plans of Personal Windows, Business
Class Windows,
Pro Windows and eCommerce Windows, you
can use ASP to
read/write to databases via an ODBC connection. You
can use both DSN or DSN-less
connections.
Microsoft
Access and Microsoft SQL server are the two most commonly used database
types on a Windows Hosting Platform, both of which are available with
the following Aplus.Net Windows-based shared hosting plans:
- Microsoft
Access: Personal Windows, Business Class Windows, Pro Windows, and
eCommerce Windows.
- Microsoft
SQL 2000: Business Class Windows (50 MB), Pro Windows (150 MB) and
eCommerce Windows (350 MB).
Note:
Please upload all you Microsoft access database files (.mdb
files) in your DB folder.
Here
is an ASP script example which illustrates how to establish a DSN-less
connection to a Microsoft Access (.mdb) database:
Note:
Please note that the example below assumes your MS Access database file
is named mydb.mdb and is uploaded into your DB folder. Please update
the path to your MS Access database in the connection string with your
plan's specific details (i.e: ftpusername,
folder
and database file name)
<html>
<head>
<title>An ASP Test Page</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database
Connection Object
Dim rsproduct 'Holds the recordset for
the records in the database
Dim strSQL 'Holds the SQL query to query
the database
'Create an ADO connection object
Set adoCon =
Server.CreateObject("ADODB.Connection")
'Set an active connection to the
Connection object using a DSN-less connection
adoCon.Open "Driver={Microsoft Access
Driver (*.mdb)};" &
"DBQ=d:\inetpub\virtual\yourusername\db\mydb.mdb;"
if adoCon.state = 1 then
Response.write ("Database Connection Established Successfully")
end if
adoCon.Close
%>
</body>
</html>
|