Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: ASP Error


Message #1 by tkitzman@h... on Sat, 20 Apr 2002 17:49:53
Could you please help me solve this error?

Error Type:
Microsoft JET Database Engine (0x80040E21)
The record cannot be deleted or changed because table 'Registration' 
includes related records.
/final/update.asp, line 36





Here is the code.


<%

dim objconn, objrs
set objconn = Server.CreateObject("ADODB.Connection")
set objrs = Server.CreateObject("ADODB.Recordset")
strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=c:\inetpub\wwwroot\final\eventregistration.mdb;Persist Security 
Info=False"
objconn.open strconnection
objrs.open "Select * from customer where customernumber = '" & Request.Form
("userid") & "'", objconn, 3, 3, 1

session("userid") = Request.form ("userid")
session("password") = Request.form ("password")
Session("firstname") = Request.form ("fname")
Session("middlename") = Request.form ("mname")
Session("lastname") = Request.form ("lname")
Session("address1") = Request.form ("address1")
Session("address2") = Request.form ("address2")
Session("city") = Request.form ("city")
Session("state") = Request.form ("state")
Session("zip") = Request.form ("zip")
Session("phone") = Request.form ("phone")
Session("email") = Request.form ("email")

objRS("customernumber") = Session("userid")
objRS("password") = Session("password")
objRS("FirstName") = Session("firstname")
objRS("MiddleName") = Session("middlename")
objRS("LastName") = Session("lastname")
objRS("Address1") = Session("address1")
objRS("Address2") = Session("address2")
objRS("City") = Session("city")
objRS("State") = Session("state")
objRS("Zip") = Session("zip")
objRS("Phone") = Session("phone")
objRS("Email") = Session("email")

objRS.Update

Response.Redirect "login.asp"





Thanks!

Tammy
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 22 Apr 2002 10:48:03 +1000
You have a constraint in your database, which prevents you from changing the
foreign key field in the child table to a value that does not exist in the
parent table.

Understanding this is fundamental to developing databases that are
relational.

For example, if you build an "online store", and you have a customers table,
and an orders table. Each order must be assigned to a valid customer. If you
try to change the CustomerID in the Orders table to a value that does not
exist in the Customers table, then you'll have an orphan record in the
Orders table that isn't assigned to any valid customer - which is a BAD
thing :-)

I suggest you check the values that you are trying to put into the database
(using Response.Write()) and make sure they are what you think they are!

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <tkitzman@h...>
Subject: [access_asp] ASP Error


: Could you please help me solve this error?
:
: Error Type:
: Microsoft JET Database Engine (0x80040E21)
: The record cannot be deleted or changed because table 'Registration'
: includes related records.
: /final/update.asp, line 36
:
: Here is the code.
:
:
: <%
:
: dim objconn, objrs
: set objconn = Server.CreateObject("ADODB.Connection")
: set objrs = Server.CreateObject("ADODB.Recordset")
: strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
: Source=c:\inetpub\wwwroot\final\eventregistration.mdb;Persist Security
: Info=False"
: objconn.open strconnection
: objrs.open "Select * from customer where customernumber = '" &
Request.Form
: ("userid") & "'", objconn, 3, 3, 1
:
: session("userid") = Request.form ("userid")
: session("password") = Request.form ("password")
: Session("firstname") = Request.form ("fname")
: Session("middlename") = Request.form ("mname")
: Session("lastname") = Request.form ("lname")
: Session("address1") = Request.form ("address1")
: Session("address2") = Request.form ("address2")
: Session("city") = Request.form ("city")
: Session("state") = Request.form ("state")
: Session("zip") = Request.form ("zip")
: Session("phone") = Request.form ("phone")
: Session("email") = Request.form ("email")
:
: objRS("customernumber") = Session("userid")
: objRS("password") = Session("password")
: objRS("FirstName") = Session("firstname")
: objRS("MiddleName") = Session("middlename")
: objRS("LastName") = Session("lastname")
: objRS("Address1") = Session("address1")
: objRS("Address2") = Session("address2")
: objRS("City") = Session("city")
: objRS("State") = Session("state")
: objRS("Zip") = Session("zip")
: objRS("Phone") = Session("phone")
: objRS("Email") = Session("email")
:
: objRS.Update
:
: Response.Redirect "login.asp"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index