<%@ LANGUAGE="VBSCRIPT" %> <% '*********************************************************************** ' System : ASPTest ' Author : Christopher Williams of CJWSoft www.CJWSoft.com ' Purpose : This code is used for testing data connections to a ' Microsoft Access database. ' ' COPYRIGHT NOTICE ' ' ' (c) Copyright 2000 - 2001 by CJWSoft. All rights reserved '*********************************************************************** %> <% '*** Below is the only setting you need to edit in this file ConnectionString = "DBQ=G:\Inetpub\abex.com\asptest\_database\asptest.mdb;Driver={Microsoft Access Driver (*.mdb)};UID=Admin;Password=temp" '*** This is using a DNS-Less connection by default '*** Comments about the above setting '*** '*** The example below shows how to use a system DSN instead of a DNS-LESS connection '*** ConnectionString = "DSN=asptest;UID=admin;PASSWORD=temp" '*** '*** The example below shows how to use a DNS-LESS connection with MSACCESS instead of a system DSN '*** ConnectionString = "DBQ=C:\Inetpub\wwwroot\asptest\_database\asptest.mdb;Driver={Microsoft Access Driver (*.mdb)};UID=Admin;Password=temp" '*** NOTE: You can not use something like "http:\\" to specify the data path.. it must be a drive location..if you don't know it ask the system admin '*** %>

ASPTest by CJWSoft

This code is used for testing data connections to a Microsoft Access database.
If you can get this working then you should have no problem installing any of the CJWSoft ASP applications.
ASPtest is very simple to use. It contains one ".asp" file called "asptest.asp" and a very simple MSACCESS database called "asptest.mdb"

To use ASPTest there is one setting in the "asptest.asp" file that you must change. It is a variable called "ConnectionString".
Edit this file with a text editor to change this setting. There are remarks that give examples of what you should change it to.
The supplied database and the "asptest.asp" file must be copied to your web server and run from there.


It is very important that permissions are set on the directory the database is in.
More info on  Connections And Server Database Permissions are available at my web site.


<% '*** This part checks the data connection reports back errors if it is not ok Err.Clear On Error Resume Next Set ConnASPTest = Server.CreateObject("ADODB.Connection") Set CmdCheckConnection = Server.CreateObject("ADODB.Recordset") ConnASPTest.Open ConnectionString If Err.Number <> 0 Then Response.Write("Failed: Database could not be connected to....

") Response.Write("") Response.Write("Error reported from server:
") Response.Write("Error source: " & Err.Source & "
") Response.Write("Error number: " & Err.Number & "
") Response.Write("Error description: " & Err.Description & "

") Response.Write("
") Err.Clear Else Response.Write("Database connected to successfully....

") DataConnectionSuccess = DataConnectionSuccess + 1 End If CmdCheckConnection.Close Set CmdCheckConnection = Nothing ConnASPTest.Close Set ConnASPTest = Nothing '*** This part checks the data connection reports back errors if it is not ok If DataConnectionSuccess = 1 Then '*** This part attempts to read a record from the database and reports back errors if it is not ok Err.Clear On Error Resume Next Set ConnASPTest = Server.CreateObject("ADODB.Connection") Set CmdCheckConnection = Server.CreateObject("ADODB.Recordset") ConnASPTest.Open ConnectionString SQL = "SELECT Configuration.* FROM Configuration WHERE (ID = 1)" CmdCheckConnection.Open SQL, ConnASPTest If Err.Number <> 0 Then Response.Write("Failed: Database record could not be retrieved....

") Response.Write("") Response.Write("Error reported from server:
") Response.Write("Error source: " & Err.Source & "
") Response.Write("Error number: " & Err.Number & "
") Response.Write("Error description: " & Err.Description & "

") Response.Write("
") Err.Clear Else Response.Write("Database record retrieved successfully....

") 'Response.Write("   Some_Value1 = " & CmdCheckConnection("Some_Value1") & "
") 'Response.Write("   Some_Value2 = " & CmdCheckConnection("Some_Value2") & "
") 'Response.Write("   Some_Value3 = " & CmdCheckConnection("Some_Value3") & "

") DataConnectionSuccess = DataConnectionSuccess + 1 End If CmdCheckConnection.Close Set CmdCheckConnection = Nothing ConnASPTest.Close Set ConnASPTest = Nothing '*** This part attempts to read a record from the database and reports back errors if it is not ok '*** This part attempts to modify a record from the database and reports back errors if it is not ok Err.Clear On Error Resume Next Set ConnASPTest = Server.CreateObject("ADODB.Connection") Set CmdCheckConnection = Server.CreateObject("ADODB.Recordset") ConnASPTest.Open ConnectionString SQL = "SELECT Configuration.* FROM Configuration WHERE (ID = 1)" CmdCheckConnection.Open SQL, ConnASPTest, 1, 3 CmdCheckConnection.Fields("Some_Value1") = "TestValue1" CmdCheckConnection.Fields("Some_Value2") = "TestValue2" CmdCheckConnection.Fields("Some_Value3") = "TestValue3" CmdCheckConnection.Update If Err.Number <> 0 Then Response.Write("Failed: Database record could not be modified....

") Response.Write("") Response.Write("Error reported from server:
") Response.Write("Error source: " & Err.Source & "
") Response.Write("Error number: " & Err.Number & "
") Response.Write("Error description: " & Err.Description & "

") Response.Write("
") Err.Clear Else Response.Write("Database record modified successfully....

") DataConnectionSuccess = DataConnectionSuccess + 1 End If CmdCheckConnection.Close Set CmdCheckConnection = Nothing ConnASPTest.Close Set ConnASPTest = Nothing '*** This part attempts to modify a record from the database and reports back errors if it is not ok '*** This part attempts to add a record to the database and reports back errors if it is not ok Err.Clear On Error Resume Next Set ConnASPTest = Server.CreateObject("ADODB.Connection") Set CmdCheckConnection = Server.CreateObject("ADODB.Recordset") ConnASPTest.Open ConnectionString SQL = "SELECT Records.* FROM Records" CmdCheckConnection.Open SQL, ConnASPTest, 1, 3 CmdCheckConnection.AddNew CmdCheckConnection.Fields("First_Name") = "Tommy" CmdCheckConnection.Fields("Last_Name") = "Tester" CmdCheckConnection.Update If Err.Number <> 0 Then Response.Write("Failed: Database record could not be added....

") Response.Write("") Response.Write("Error reported from server:
") Response.Write("Error source: " & Err.Source & "
") Response.Write("Error number: " & Err.Number & "
") Response.Write("Error description: " & Err.Description & "

") Response.Write("
") Err.Clear Else Response.Write("Database record added successfully....

") DataConnectionSuccess = DataConnectionSuccess + 1 AttemptDelete = True End If CmdCheckConnection.Update ID = CmdCheckConnection("ID") CmdCheckConnection.Close Set CmdCheckConnection = Nothing ConnASPTest.Close Set ConnASPTest = Nothing '*** This part attempts to add a record to the database and reports back errors if it is not ok '*** This part attempts to delete a record from the database and reports back errors if it is not ok If AttemptDelete = True Then Err.Clear On Error Resume Next Set ConnASPTest = Server.CreateObject("ADODB.Connection") Set CmdCheckConnection = Server.CreateObject("ADODB.Recordset") ConnASPTest.Open ConnectionString SQL = "DELETE From Records WHERE (ID = " & ID & ")" CmdCheckConnection.Open SQL, ConnASPTest, 1, 3 If Err.Number <> 0 Then Response.Write("Failed: Database record could not be deleted....

") Response.Write("") Response.Write("Error reported from server:
") Response.Write("Error source: " & Err.Source & "
") Response.Write("Error number: " & Err.Number & "
") Response.Write("Error description: " & Err.Description & "

") Response.Write("
") Err.Clear Else Response.Write("Database record deleted successfully....

") DataConnectionSuccess = DataConnectionSuccess + 1 End If CmdCheckConnection.Update ID = CmdCheckConnection("User_ID") Attempt Delete = True CmdCheckConnection.Close Set CmdCheckConnection = Nothing ConnASPTest.Close Set ConnASPTest = Nothing End If '*** This part attempts to delete a record from the database and reports back errors if it is not ok End If %>
<% Response.Write("
") If DataConnectionSuccess = 5 Then Response.Write("
You appear to have a correctly set up data connection
") Else Response.Write("
There are errors with your data connection. You must correct these errors.
") End If Response.Write("
") %>