Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 December 30th, 2004, 10:14 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch15 adduser.asp problem beginning asp 3

hi,
l'm stuck on adding new users to my access database, using the code that's in the book, l don't get any error message apart from when l add a new user it overwrites the previous one, I have the PersonID field set to autonumber in the database and have checked the location of the dbase that's in the Clssfd.asp file and following is the code from the book:


<%
  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"
%>

everything else works that's part of the example website in the book apart from this.

any suggestions

many thanks


ellie
 
Old December 30th, 2004, 01:49 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I am not an asp guru by any means, but it appears on first glance that the code checks to see if a user is present, and if not it adds a record. If the user is present it then updates the record that is already in the database, which means it would overwrite the record that you already have. Others could probably shed more light on this, and you may want to try the Access ASP forum instead of this one.

Best of luck

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with chapter 3 of Beginning ASP.NET2.0 C# hedgracer ASP.NET 2.0 Basics 1 April 26th, 2008 08:49 AM
Beginning ASP 3.0, Chapter 12 (Connect.asp). Richard LaChance BOOK: Beginning ASP 3.0 4 July 24th, 2004 04:12 PM
Syntax error for chapter 15 AddUser.asp gymmic Classic ASP Databases 7 April 20th, 2004 02:00 AM
getting problem while beginning ASP.NET creative_eye .NET Web Services 2 February 3rd, 2004 07:59 AM





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