|
 |
access_asp thread: Trouble adding record, please help
Message #1 by "Silas Reyes" <sciseven@h...> on Thu, 28 Feb 2002 18:46:24
|
|
Below is the ERROR, I get:
*************************************************
Microsoft JET Database Engine error '80040e21'
You cannot add or change a record because a related record is required in
table 'tblSchoolDetail'.
/cps/addnewProc.asp, line 120
*************************************************
NOTES:
I get this error when I check Referential Integrity on the table
relationships.
If I uncheck Referential Integrity, I am able to insert the record but
when I look at the tables in Access, the joined fields are 0. For example,
tblSchoolDetail.school_detail_id = 1 but in
tblSchoolInfo.school_detail_id, it is 0 when it should be 1 as in the
tblSchoolDetail table.
***************CODE*****************************
<%
Option Explicit
Dim strConnect
%>
<!-- #include file="strConnect.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim strSQL 'SQL command string to execute
Dim objRs 'The ADODB recordset object
strSQL = "SELECT tblSchoolDetail.school_detail_id,
tblSchoolInfo.school_info_id
FROM tblSchoolDetail INNER JOIN tblSchoolInfo ON
tblSchoolDetail.school_detail_id = tblSchoolInfo.school_detail_id;"
Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open strSQL, strConnect, adOpenStatic, adLockOptimistic, adCmdText
objRs.AddNew 'add a new record
'Records to add from form
objRs("school_info_id") = Request.Form("SchoolInfoID")
objRs("school_detail_id") = Request.Form("SchoolDetailID")
objRs.Update
objRs.Close
Set objRs = Nothing
objConn.Close
Set objConn = Nothing
%>
|
|
 |