ASP Database support
• Introduction
• Checking objects
• Copying databases
• Creating databases
• Database connections
• Database browser
|
|
Putting a database-driven website on CD
|
This section of the documentation primarily deals with ASP Dynamic-CD.
For information on ASP.NET Dynamic-CD.Net databases, please see here.
If you have a website that is generated from a database, or uses a database to
present or collect information, you can put your website on an ASP
Dynamic-CD with little or no
effort.
|
If you are having trouble getting a database to work using
Dynamic-CD, the most likely cause is a faulty connection string.
For details about how to connect to your database,
.
|
Whether or not the user has MS ACCESS® installed on their machine,
recent Windows platforms (Windows 98 second edition and later) come with database support
already loaded in the form of ADODB and ADOX objects.
These objects can be used by Dynamic-CD to
create, query, modify or delete MS ACCESS databases.
If your site database is not MS ACCESS, most databases can be converted to MS ACCESS,
or if a driver for your database is available, this can be used instead of the drivers
discussed here. We have only tested Dynamic-CD with MS ACCESS
databases.
The issues you need to take into account when transferring a database-driven website
to CD include the following
Does the user's machine have ADODB support loaded?
The principal component required for database support is
ADODB.Connection. To test the presence of this component,
use the following code.
<%
SUB checkADODB
if Session( "ADODBok") then EXIT SUB
' find out whether the ADODB object exists
ON Error Resume Next
Set thisObj = Server.CreateObject( "ADODB.Connection")
if Err = 0 then
Session( "ADODBok") = true
EXIT SUB
else
Err.Clear
showFailMsg( "database access")
end if
END SUB
' ---------------
SUB showFailMsg( msg)
%>
Sorry, your operating system does not support <%=msg%>.
<BR>Please try running Dynamic-CD on a more recent system.
<BR>
Your operating system is
<%
Response.Write( Request.ServerVariables( "WINDOWS_OS"))
Response.End
END SUB
%>
|
This code can be stored in a library file and included in all scripts that need
database support :
<!-- #INCLUDE FILE="adodbSupportLib.asp" -->
<%
checkADODB
... more code ...
%>
|
If the presence of the component has been checked already, the Session variable
saves having to load the component again. If the component is not supported, the
failure message stops any further processing, or can transfer to another script that
informs the user where to download this database support.
Further information can be reported as follows :
<%
ON ERROR RESUME NEXT
SET ourObj = Server.CreateObject( "ADODB.Connection")
Response.Write "<BR>ADODB "
IF ERR <> 0 THEN
Response.Write "is not "
ELSE
Response.Write "version " + ourObj.Version + " is "
END IF
Response.Write "installed on this machine"
Err.Clear
SET ourObj = Server.CreateObject( "ADOX.Catalog")
Response.Write "<BR>ADOX is "
IF ERR <> 0 THEN
Response.Write "not "
END IF
Response.Write "installed on this machine"
Err.Clear
SET ourObj = nothing
%>
|
Result of running this script on this machine :
ADODB version 10.0 is installed on this machineADOX is installed on this machine
Does the user's machine have FileSystemObject support loaded?
If you need to create a new database on the user's hard disk, or manipulate or delete files
on their hard disk, you may need to test for file system support.
This can be done as follows :
<%
SUB checkFSO
if Session( "FSOok") then EXIT SUB
' find out whether Scripting object exists
ON Error Resume Next
Set thisObj = Server.CreateObject( "Scripting.FileSystemObject")
if Err = 0 then
Session( "FSOok") = true
EXIT SUB
else
Err.Clear
showFailMsg( "access to the file system")
end if
END SUB
%>
|
|