Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2004, 02:06 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default addnew problem

Hi. I downloaded the source code for Chapter 15 example of "beginning asp 3.0". When i test (use win2000 server), the pages including code of "addnew" or "update" don't work and always appear a error page. But the other pages are ok.
Why can't I update the database? Can u help?


 
Old February 17th, 2004, 06:28 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What error message do you recive when the page errors out?

 
Old February 23rd, 2004, 02:21 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Post your code too.

 
Old February 24th, 2004, 01:00 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the Registration page's code:
<BASEFONT FACE="Comic Sans MS" COLOR="DarkBlue">
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
  function VerifyData()
  {
    if (document.frmUser.Password.value != document.frmUser.VerifyPassword.value)
    {
      alert ("Your passwords do not match - please reenter");
      return false;
    }
    else
      return true;
  }
-->
</SCRIPT>

<TITLE>Wrox Classifieds - User Registration</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFF80">
<CENTER>
<%
  If Request("Update") = "True" Then
    Response.Write "<H1>Wrox Classifieds<BR> Update User Registration</H1>"
  Else
    Response.Write "<H1>Wrox Classifieds<BR> New User Registration</H1>"
  End If
%>
</CENTER>
<P>

<%
  If Request("Update") = "True" Then
    Response.Write "Please change your registration information as listed below<P>"
  Else
    If Request("NotFound") = "True" Then
      Response.Write "<I>We were unable to locate your information. " & _
                     "Please take the time to register again.</I><P>"
    Else
      Response.Write "<CENTER>(If you're already registered with us, " & _
                     "then click the 'Login' link below.)</CENTER><P>"
    End If
    Response.Write "You only need to register with our system if you want to " & _
                   "bid on existing 'for-sale' items, or sell your own items " & _
                   "on these pages. <BR> " & _
                   "In order to use these services, please take a few minutes " & _
                   "to complete the form below. Once you have done that, " & _
                   "you will have full access to the system."
  End If
%>

<FORM ACTION="AddUser.asp" NAME="frmUser" METHOD="POST"
              onSubmit="return VerifyData()">
  <TABLE BORDER=0>
    <TR>
      <TD WIDTH=20% ROWSPAN=11>&nbsp;</TD>
      <TD>E-Mail Address:</TD>
      <TD><INPUT TYPE="Text" NAME="email" VALUE="<%= Session("EMailAddress")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Given Name:</TD>
      <TD><INPUT TYPE="Text" NAME="GivenName" VALUE="<%= Session("GivenName")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Family Name:</TD>
      <TD><INPUT TYPE="Text" NAME="FamilyName" VALUE="<%= Session("FamilyName")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Address:</TD>
      <TD><INPUT TYPE="Text" NAME="Address1" VALUE="<%= Session("StreetAddress1")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD></TD>
      <TD><INPUT TYPE="Text" NAME="Address2" VALUE="<%= Session("StreetAddress2")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>City:</TD>
      <TD><INPUT TYPE="Text" NAME="City" VALUE="<%= Session("City")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>State:</TD>
      <TD><INPUT TYPE="Text" NAME="State" VALUE="<%= Session("State")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Postal Code:</TD>
      <TD><INPUT TYPE="Text" NAME="PostalCode" VALUE="<%= Session("PostalCode")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Country:</TD>
      <TD><INPUT TYPE="Text" NAME="Country" VALUE="<%= Session("Country")%>"
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>&nbsp;<P>Password:</TD>
      <TD VALIGN=bottom><INPUT TYPE="Password" NAME="Password"
                         VALUE="<%= Session("Password") %>" SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Verify Password:</TD>
      <TD><INPUT TYPE="Password" NAME="VerifyPassword" SIZE="40"></TD>
    </TR>
    <TR>
      <TD></TD>
      <TD ALIGN=CENTER COLSPAN=2><BR>
          <INPUT TYPE="Submit" VALUE="Submit Registration">
              &nbsp;&nbsp;<INPUT TYPE="RESET"></TD>
    </TR>
  </TABLE>
</FORM>


<TABLE BORDER=0 WIDTH=100%>
  <TR ALIGN=CENTER>
    <TD WIDTH=33%><A HREF="BrowseListings.asp">Browse the listings</A></TD>
    <TD WIDTH=33%><A HREF="Login.asp">Login</A></TD>
    <TD WIDTH=33%>I'm a new user</TD>
  </TR>
</TABLE>

</BODY>
</HTML>


 
Old February 24th, 2004, 01:03 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the adduser page(adduser.asp)'s code:


<%
  Dim rsUsers
  Set rsUsers = Server.CreateObject("ADODB.Recordset")
  rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable

  If Session("PersonID") <> "" Then ' currently logged-on user
    rsUsers.Filter = "PersonID = '" & Session("PersonID") & "'"
  Else ' New session
    rsUsers.Filter = "EMailAddress = '" & Request.Form("email") & "'" & _
                     "AND Password = '" & Request.Form("password") & "'"
    If rsUsers.EOF Then ' User not found
      rsUsers.AddNew ' ...so add a new record
' Else
' Email address and password matched with DB records -
' In this case we'll allow this to update user's personal details
    End If
  End If
                                                  ' write personal details to record
  rsUsers("EMailAddress") = Request.Form("email")
  rsUsers("Password") = Request.Form("password")
  rsUsers("FamilyName") = Request.Form("FamilyName")
  rsUsers("GivenName") = Request.Form("GivenName")
  rsUsers("StreetAddress1") = Request.Form("Address1")
  rsUsers("StreetAddress2") = Request.Form("Address2")
  rsUsers("City") = Request.Form("City")
  rsUsers("State") = Request.Form("State")
  rsUsers("PostalCode") = Request.Form("PostalCode")
  rsUsers("Country") = Request.Form("Country")
  rsUsers("Active") = True
  rsUsers("LastLogin") = Now
  rsUsers.Update ' update the database

  Dim strName, strValue ' create session variables
  For each strField in rsUsers.Fields
    strName = strField.Name
    strValue = strField.value
    Session(strName) = strValue
  Next
  Session("blnValidUser") = True ' declare that current user is validated
  Response.Redirect "MenuForRegisteredUsers.asp"
%>



 
Old February 24th, 2004, 01:05 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the clssfd.asp:
<%
  Dim objConn
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
               "Data Source= C:\inetpub\wwwroot\test\basp\classified_2000.mdb"

  If Session("blnValidUser") = True and Session("PersonID") = "" Then
    Dim rsPersonIDCheck
    Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
    Dim strSQL
    strSQL = "SELECT PersonID FROM Person " & _
             "WHERE EMailAddress = '" & Session("EMailAddress") & "';"
    rsPersonIDCheck.Open strSQL, objConn
    If rsPersonIDCheck.EOF Then
      Session("blnValidUser") = False
    Else
      Session("PersonID") = rsPersonIDCheck("PersonID")
    End If
    rsPersonIDCheck.Close
    Set rsPersonIDCheck = Nothing
  End If
%>

 
Old February 24th, 2004, 01:08 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the error happans in adduser page(adduser.asp).
error type:
Microsoft JET Database Engine (0x80040E09)
/test/basp/AddUser.asp, 21st line






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help regarding Addnew Kaustav Classic ASP Databases 8 January 10th, 2010 06:33 PM
AddNew with SQL Server... neo_jakey Classic ASP Databases 0 April 16th, 2008 01:26 PM
Addnew with oracle mail4nrs Classic ASP Databases 0 August 23rd, 2004 10:10 AM
.addnew for Ado.net? paulwalker ADO.NET 1 September 20th, 2003 10:17 AM
addnew method jesuseyi Classic ASP Databases 1 August 27th, 2003 02:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.