Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 March 20th, 2005, 03:07 AM
Authorized User
 
Join Date: Mar 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding new user to the database

Hello:
I am having problem in adding new user registration to the database using ASP.What i want is when the user enter his personel information that information should be updated in the required database but it's giving me the following error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/begaspfiles/adduser1.asp, line 10


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Page:
POST 109 bytes to /begaspfiles/adduser1.asp

POST Data:
email=&GivenName=&FamilyName=&Address1=&Address2=& City=&State=&PostalCode=&Country=&Password=&Verify Password=
Here is the code that i am using to add the new user to the database.
file adduser1:

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

  If Session("ID") <> "" Then ' currently logged-on user
    rsUsers.Filter = "ID = '" & Session("ID") & "'"
  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")


  Dim strName, strValue ' create session variables
  For each strField in rsUsers.Fields
    strName = strField.Name
    strValue = strField.value
    Session(strName) = strValue
  Next
  Session("") = True ' declare that current user is validated
  Response.Redirect "MenuForRegisteredUsers.asp"
%>
file Clssfd1:
<!-- METADATA TYPE="typelib"
              FILE="D:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
  Dim objConn
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
               "Data Source= D:\Inetpub\wwwroot\begaspfiles\newuser.mdb"

  If Session("blnValidUser") = True and Session("ID") = "" Then
    Dim rsIDCheck
    Set rsIDCheck = Server.CreateObject("ADODB.Recordset")
    Dim strSQL
    strSQL = "SELECT ID FROM newuser1 " & _
             "WHERE EMailAddress = '" & Session("EMailAddress") & "';"
    rsPersonIDCheck.Open strSQL, objConn
    If rsPersonIDCheck.EOF Then
      Session("") = False
    Else
      Session("ID") = rsIDCheck("ID")
    End If
    rsIDCheck.Close
    Set rsIDCheck = Nothing
  End If
%>
file newuser:
<BASEFONT FACE="Arial" COLOR="#FFFFFF">
<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>Banana Vehicle Parts - User Registration</TITLE>
</HEAD>
<BODY BGCOLOR="#000000">
<center>
<img name="n00000001" src="Banana_Motors1.jpg" width="756" height="172" border="0"

usemap="#m_00000001" alt=""><map name="m_00000001">
<area shape="rect" coords="668,153,721,165" href="http://chinese-jvzfdjb/begaspfiles/terms.asp"

target="_self" alt="" >
<area shape="rect" coords="538,153,614,165" href="http://chinese-jvzfdjb/begaspfiles/logoff.asp"

target="_self" alt="" >
<area shape="rect" coords="394,153,491,165"href="http://chinese-jvzfdjb/begaspfiles/checkout.asp"

target="_self" alt="" >
<area shape="rect" coords="256,153,375,165"

href="http://chinese-jvzfdjb/begaspfiles/catalog3.asp" target="_self" title="shop" alt="shop" >
<area shape="rect" coords="138,153,236,165"

href="http://chinese-jvzfdjb/begaspfiles/managecart.asp" target="_self" alt="" >
<area shape="rect" coords="37,153,80,165" href="http://chinese-jvzfdjb/begaspfiles/login.asp"

target="_self" alt="" >
</map>

</center>
<CENTER>
<img src="D:\Inetpub\wwwroot\begaspfiles\new.jpg">
<a href="http://chinese-jvzfdjb/begaspfiles/site_search.asp"><img

src="D:\Inetpub\wwwroot\begaspfiles\search.jpg" border="0"></a>
</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>"

    End If
    Response.Write "In order to use our 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="adduser1.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=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Given Name:</TD>
      <TD><INPUT TYPE="Text" NAME="GivenName" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Family Name:</TD>
      <TD><INPUT TYPE="Text" NAME="FamilyName" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Address1:</TD>
      <TD><INPUT TYPE="Text" NAME="Address1" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Address2:</TD>
      <TD><INPUT TYPE="Text" NAME="Address2" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>City:</TD>
      <TD><INPUT TYPE="Text" NAME="City" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>State:</TD>
      <TD><INPUT TYPE="Text" NAME="State" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Postal Code:</TD>
      <TD><INPUT TYPE="Text" NAME="PostalCode" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>Country:</TD>
      <TD><INPUT TYPE="Text" NAME="Country" VALUE=""
           SIZE="40"></TD>
    </TR>
    <TR>
      <TD>&nbsp;<P>Password:</TD>
      <TD VALIGN=bottom><INPUT TYPE="password" NAME="Password"
                         VALUE="" 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>
</BODY>
</HTML>
Please can anybody help me with this problem sooner.
Thankyou.

 
Old March 21st, 2005, 01:34 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please check the column names used in the program. These column names should be same as in the table.

Om Prakash





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding User Forms at Run time RichRansom BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 May 30th, 2008 11:49 AM
Adding Controls to User Control bmains C# 2005 0 June 5th, 2006 09:09 PM
adding new worksheet using user form sime_tyres Excel VBA 1 February 21st, 2006 12:35 AM
Problem with adding user to database ali786 Classic ASP Databases 3 March 11th, 2005 01:33 AM
Problem with adding user to dabase ali786 Classic ASP Databases 0 March 9th, 2005 06:34 AM





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