|
Subject:
|
addnew problem
|
|
Posted By:
|
ponywang@hotmail.com
|
Post Date:
|
2/10/2004 1:06:18 AM
|
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?
|
|
Reply By:
|
pab006
|
Reply Date:
|
2/17/2004 5:28:06 AM
|
What error message do you recive when the page errors out?
|
|
Reply By:
|
DaveGerard
|
Reply Date:
|
2/23/2004 1:21:58 AM
|
Post your code too.
|
|
Reply By:
|
ponywang@hotmail.com
|
Reply Date:
|
2/24/2004 12:00:02 AM
|
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> </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> <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"> <INPUT TYPE="RESET"></TD> </TR> </TABLE> </FORM>
<HR> <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>
|
|
Reply By:
|
ponywang@hotmail.com
|
Reply Date:
|
2/24/2004 12:03:12 AM
|
the adduser page(adduser.asp)'s code: <!--#include file="Clssfd.asp"--> <!-- #include file="adovbs.inc" --> <% 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" %>
|
|
Reply By:
|
ponywang@hotmail.com
|
Reply Date:
|
2/24/2004 12:05:02 AM
|
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 %>
|
|
Reply By:
|
ponywang@hotmail.com
|
Reply Date:
|
2/24/2004 12:08:09 AM
|
the error happans in adduser page(adduser.asp). error type: Microsoft JET Database Engine (0x80040E09) /test/basp/AddUser.asp, 21st line
|