ASP & DB Help revisited
by "Keith Parker" <diades(at)diades.screaming.net>
|
Date: |
Wed, 9 Feb 2000 10:27:53 -0000 |
To: |
"Jessica Sarol" <jsarol(at)startek.com>, "Dahlstrom, Marie" <marie.dahlstrom(at)se.unisys.com> |
Cc: |
"HWG Languages" <hwg-languages(at)hwg.org> |
References: |
|
|
todo: View
Thread,
Original
|
|
Hi,
Thanks for the replies, I have include the code that I am using below. I
have not worried, as yet about layout etc., etc., I just want to get the
thing working the rest can follow.
++++++++++++++++++++++++++++++++++++++
contact.asp
++++++++++++++++++++++++++++++++++++++
<!-- #Include file="inc/adovbs.inc" -->
<% Language = VBScript %>
<!--#include file="inc/values.inc"-->
<HTML><HEAD><TITLE>Advanced Data Services - Contact Form</TITLE>
<link href="styles/adsIE.css" rel="stylesheet" type="text/css">
</HEAD>
<!--#include file="inc/navfunc.inc"-->
<BODY>
<Center><H3>Leave us a message</H3>
<!--#include file="inc/menu.inc"-->
<!-- ADO Connection Object used to create recordset-->
<%
'Create and Open Connection Object
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "msgs","",""
'Create and Open Recordset Object
Set contact_rst = Server.CreateObject("ADODB.Recordset")
contact_rst.ActiveConnection = conn
contact_rst.CursorType = adOpenKeyset
contact_rst.LockType = adLockOptimistic
contact_rst.Source = "tblmessage"
contact_rst.Open %>
<!-- If this is the first time the page is opened, the Form collection will
be empty when data is entered
run AddNew method-->
<%
If Not IsEmpty(Request.Form) Then
If Not Request.Form("ddName") = "" Then
contact_rst.AddNew
'ddMsgNdx - Automatic index within .mdb table
contact_rst("ddName") = Request.Form("ddName")
contact_rst("ddEmail") = Request.Form("ddEmail")
contact_rst("ddTitle") = Request.Form("ddTitle")
contact_rst("ddPosition") = Request.Form("ddPosition")
contact_rst("ddCompany") = Request.Form("ddCompany")
contact_rst("ddTelephone1") = Request.Form("ddCCode")
contact_rst("ddTelephone2") = Request.Form("ddACode")
contact_rst("ddTelephone3") = Request.Form("ddTelephone")
contact_rst("ddExt") = Request.Form("ddExt")
contact_rst("ddFax") = Request.Form("ddFax")
contact_rst("ddStreet") = Request.Form("ddStreet")
contact_rst("ddArea") = Request.Form("ddArea")
contact_rst("ddCity") = Request.Form("ddCity")
contact_rst("ddPostCode") = Request.Form("ddPostCode")
contact_rst("ddCountry") = Request.Form("ddCountry")
contact_rst("ddAdvise") = Request.Form("ddAdvise")
contact_rst("ddSubject") = Request.Form("ddSubject")
contact_rst("ddMessage") = Request.Form("ddMessage")
'ddMessageDate - left to default to the system date
contact_rst.Update
contact_rst.MoveFirst
End If
End If
%>
<table COLSPAN="8" CELLPADDING="5" BORDER="1">
<!-- BEGIN column header row for Customer Table-->
<tr>
<td ALIGN="CENTER">Message Number</td>
<td ALIGN="CENTER">Name</td>
<td ALIGN="CENTER">Title</td>
<td ALIGN="CENTER">Position</td>
<td ALIGN="CENTER">Company</td>
<td ALIGN="CENTER">Country Code</td>
<td ALIGN="CENTER">Area Code</td>
<td ALIGN="CENTER">Telephone No</td>
<td ALIGN="CENTER">Extension</td>
<td ALIGN="CENTER">Fax</td>
<td ALIGN="CENTER">E-mail</td>
<td ALIGN="CENTER">Street</td>
<td ALIGN="CENTER">Area</td>
<td ALIGN="CENTER">>Town/City</td>
<td ALIGN="CENTER">Post/Zip Code</td>
<td ALIGN="CENTER">Country</td>
<td ALIGN="CENTER"Advise</td>
<td ALIGN="CENTER">Subject</td>
<td ALIGN="CENTER">Message</td>
<td ALIGN="CENTER"Message Sent</td>
</tr>
<!--Display ADO Data from Customer Table One row on each pass through
recordset-->
<% Do While Not contact_rst.EOF %>
<tr>
<td><%= contact_rst("MsgNdx")%></td>
<td><%= contact_rst("ddName") & ", " %></td>
<td><%= contact_rst("ddTitle")%></td>
<td><%= contact_rst("ddPosition")%></td>
<td><%= contact_rst("ddCompany")%></td>
<td><%= contact_rst("ddTelephone1")%></td>
<td><%= contact_rst("ddTelephone2")%></td>
<td><%= contact_rst("ddTelephone3")%></td>
<td><%= contact_rst("ddExt")%></td>
<td><%= contact_rst("ddFax")%></td>
<td><%= contact_rst("ddEmail")%></td>
<td><%= contact_rst("ddStreet")%></td>
<td><%= contact_rst("ddArea")%></td>
<td><%= contact_rst("ddCity")%></td>
<td><%= contact_rst("ddPostCode")%></td>
<td><%= contact_rst("ddCountry")%></td>
<td><%= contact_rst("ddAdvise")%></td>
<td><%= contact_rst("ddSubject")%></td>
<td><%= contact_rst("ddMessage")%></td>
<td><%= contact_rst("ddMessageDate")%></td>
</tr>
<!-- Next Row = Record Loop and add to row html table-->
<% contact_rst.MoveNext
Loop %>
</table>
<hr>
<!-- Form to enter new record posts variables back to this page -->
<form Method="Post" Action="contact.asp" Name="Form">
<table border="1">
<tr><td width="100%"><h2>Required Information</h2></td></tr>
<tr><td width="100%">
<table border="1" width="563"><tr>
<td width="54">Title</td>
<td width="47">Name</td>
<td width="202"><input Type="Text" maxlength="30" Size="21" Name="ddName"
Value></td>
<td width="51">E-mail</td>
<td width="73"><input Type="Text" maxlength="50" Size="7" Name="ddEmail"
Value></td>
</tr><tr>
<td width="54">Advise</td>
<td width="100"><input type="radio" name="ddAdvise" value=1>Yes<input
type="radio"
name="ddAdvise" value=0 checked>No</td>
<td width="47">Subject</td>
<td colspan="3" width="338"><input Type="Text" maxlength="50" Size="36"
Name="ddSubject"
Value></td></tr><tr>
<td width="54">Message</td>
<td colspan="5" width="497"><textarea rows="2" name="ddMessage"
cols="53"></textarea></td>
</tr></table></td></tr><tr>
<td width="100%"><h2>Other Details</h2>
</td></tr><tr>
<td width="100%"><table border="1" width="581">
<tr>
<td width="51">Position</td>
<td width="179"><input Type="Text" maxlength="10" Size="10"
Name="ddPosition" Value></td>
<td width="61">Company</td>
<td width="266"><input Type="Text" maxlength="50" Size="31" Name="ddCompany"
Value></td>
</tr></table></td></tr><tr>
<td width="100%"><h2>Location:</h2>
</td></tr><tr>
<td width="100%"><table border="1" width="486">
<tr>
<td width="51">Country Code</td>
<td width="45"><input Type="Text" maxlength="10" Size="7" Name="ddCCode"
Value></td>
<td width="45">Area Code</td>
<td width="89"><input Type="Text" maxlength="10" Size="6" Name="ddACode"
Value></td>
<td width="61">Telephone No</td>
<td width="173"><input Type="Text" maxlength="20" Size="10"
Name="ddTelephone" Value></td>
<td width="147" colspan="2">Extension</td>
<td width="98"><input Type="Text" maxlength="10" Size="5" Name="ddExt"
Value></td>
</tr><tr>
<td width="51">Fax</td>
<td width="179" colspan="3"><input Type="Text" maxlength="10" Size="7"
Name="ddFax" Value></td>
<td width="61"> </td>
<td width="418" colspan="4"> </td>
</tr><tr>
<td width="51">Street</td>
<td width="179" colspan="3"><input Type="Text" maxlength="30" Size="25"
Name="ddStreet"
Value></td>
<td width="61">Area</td>
<td width="418" colspan="4"><input Type="Text" maxlength="30" Size="21"
Name="ddArea"
Value></td>
</tr><tr>
<td width="51">Town/City</td>
<td width="179" colspan="3"><input Type="Text" maxlength="30" Size="21"
Name="ddCity"
Value></td>
<td width="61">Post/Zip Code</td>
<td width="209" colspan="2"><input Type="Text" maxlength="16" Size="10"
Name="ddPCode"
Value></td>
<td width="111">Country</td>
<td width="98"><input Type="Text" maxlength="30" Size="6" Name="ddCountry"
Value></td>
</tr><tr>
<td width="230" colspan="4"><input Type="Submit" Value=" Send "></td>
<td width="479" colspan="5"><input Type="Reset" Value="Reset Form"></td>
</tr></table></td></tr></table></form>
<p> </p>
<!-- Form to enter new record posts variables back to this page -->
<script Language="VBScript">
Sub Form_OnSubmit
MsgBox "Sending New Message to ADS",,"Message for ADS"
End Sub
</script>
<%If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<P>"
response.write "Error Descr.=" & err.description & "<P>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
else
response.write "No problems occured!" & "<P>"
end if
IF conn.errors.count> 0 then
response.write "Database Errors Occured" & "<P>"
for counter= 0 to conn.errors.count
response.write "Error #" & conn.errors(counter).number & "<P>"
response.write "Error desc. -> " & conn.errors(counter).description &
"<P>"
next
end if
%>
</body>
</html>
----- Original Message -----
From: Dahlstrom, Marie <marie.dahlstrom(at)se.unisys.com>
To: 'Keith Parker' <diades(at)diades.screaming.net>
Sent: Wednesday, February 09, 2000 7:48 AM
Subject: RE: ASP & DB Help
> Keith,
>
> You get this error for virtually any mistake you make in the line. If you
> could send a code snippet (sorry I don't understand what PWS means) I
might
> be able to see if you made any mistake.
>
> Regards
> Marie Dahlstrom
>
> -----Original Message-----
> From: Keith Parker [mailto:diades(at)diades.screaming.net]
> Sent: den 8 februari 2000 21:45
> To: HWG Languages
> Subject: ASP & DB Help
>
>
> Hi,
>
> I am hoping that you can help me!
>
> I am developing a site that requires a "contact me" page. To achieve
this,
> I have selected Access as the database, (there will not be much traffic),
> and am using ASP with ADO.
>
> Now as this is my first time doing this, I used the asp sample
> for .AddNew provided with PWS and "changed the story" to fit with my
fields
> etc.
>
> The connection is up and running and sends data from the database to the
> page but, when I fill in the form to add a record, everything is fine
until
> the script gets to [recordset].Update whereupon the following gets shown
on
> screen:
> --------
> Microsoft OLE DB Provider for ODBC Drivers error '80004005'
>
> [Microsoft][ODBC Microsoft Access Driver]Error in row
>
> /contact.asp, line 45
> --------
>
> Line 45 being the [recordset].Update method
>
> Can you shed any light please?
>
> Thanks,
>
> Keith Parker
>
> mailto://keith.parker(at)diades.co.uk
>
> http://www.diades.co.uk
>
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA