Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record
code คือ
<%
if request("Submit") = "OK" then
Dim Conn
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.open "DBQ=" & Server.MapPath ("test_project_update.mdb" )&";Driver={Microsoft Access Driver (*.mdb)}"
Sql="Select count(*) as count_user from user WHERE username = '" & request.form("user_name") & "'"
'response.Write(Sql)
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
temp_dup = 0
if RS("count_user") > 0 then
temp_dup = 1
else
Sql1 = "INSERT INTO customer(customer_name,contract_person,address,tel,fax) " & _
" values('" & request.form("customer_name") & "','" & request.form("contract_person") & "'," & _
"'" & request.form("address") & "','" & request.form("tel") & "','" & request.form("fax") & "')"
'response.write(Sql1)
Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = Conn
oCmd.CommandText = Sql1
oCmd.Execute
Set oRSe1 = Server.CreateObject("ADODB.Recordset")
SQL1 = "SELECT max(id_customer) as max_cus FROM customer "
oRSe1.Open SQL1,Conn,1,3
max_cus = oRSe1.fields("max_cus")
'Response.Write(max_cus)
Sql1 = "INSERT INTO user(id,username,password,Clearance) values(" & max_cus & ",'" & request.form("user_name") & "'," & _
"'" & request.form("password") & "','3')"
'response.write(Sql1)
Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = Conn
oCmd.CommandText = Sql1
oCmd.Execute
response.redirect("register_complete.asp")
end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="INCLUDE/StyleSheet.css" rel=stylesheet type=text/css>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<script>
function check_form()
{
if ( document.form1.user_name.value == "" )
{
alert("กรุณากรอก UserName");
document.form1.user_name.focus();
return false;
}
if ( document.form1.password.value == "" )
{
alert("กรุณากรอก Password");
document.form1.password.focus();
return false;
}
if ( document.form1.customer_name.value == "" )
{
alert("กรุณากรอก ชื่อลูกค้า");
document.form1.customer_name.focus();
return false;
}
if ( document.form1.contract_person.value == "" )
{
alert("กรุณากรอก ชื่่อหรือบริษัทที่ติดต่อ");
document.form1.contract_person.focus();
return false;
}
if ( document.form1.tel.value == "" )
{
alert("กรุณากรอก เบอร์โทรศัพท์");
document.form1.tel.focus();
return false;
}
if ( document.form1.address.value == "" )
{
alert("กรุณากรอก ที่อยู่");
document.form1.address.focus();
return false;
}
return true;
}
</script>
<script language ="javascript">
var checkcharsemail="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.@-";
// Build Numeric Validation Script OnKeypress
function FilterNumeric(){
var re;
var ch = String.fromCharCode(event.keyCode);
if(event.keyCode < 32){
return;
}
if((event.keyCode <= 57)&&(event.keyCode >= 48)){
if(!event.shiftKey){
return;
}
}//end if
if(ch == '-'){
return;
}
alert("กรุณากรอกเฉพาะตัวเลข");
event.returnValue = false;
}
function FilterEMail()
{
if(checkcharsemail.indexOf(String.fromCharCode(event.keyCode)) == -1)
event.returnValue = false;
}
</script>
<body bgcolor="#deedfc">
<form name="form1" method="post" action="register.asp">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"><div align="center"><strong>สมัครสมาชิก</strong></div></td>
</tr>
<tr>
<td width="19%"><strong>UserName :</strong></td>
<td width="33%"><input name="user_name" type="text" id="user_name" maxlength="50" /></td>
<td width="20%"><strong>Password : </strong></td>
<td width="28%"><input name="password" type="password" id="password" /></td>
</tr>
<tr>
<td><strong>ชื่อลูกค้า :</strong></td>
<td><input name="customer_name" type="text" id="customer_name" maxlength="50" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>ชื่อหรือบริษัทที่มาติดต่อ :</strong></td>
<td><input name="contract_person" type="text" id="contract_person" maxlength="50" /></td>
<td><strong>โทรศัพท์:</strong></td>
<td><input name="tel" type="text" id="tel" maxlength="255" onKeyPress="FilterNumeric();" /></td>
</tr>
<tr>
<td><strong>ที่อยู่ :</strong></td>
<td colspan="3">
<input name="address" type="text" id="address" size="44" maxlength="255" /></td>
</tr>
<tr>
<td><strong>แฟกซ์:</strong></td>
<td><input name="fax" type="text" id="fax" maxlength="50" onKeyPress="FilterNumeric();"/></td>
<td> </td>
<td><label></label></td>
</tr>
<tr>
<td> </td>
<td><% if temp_dup = 1 then %>
<span class="style1">มีชื่อ Username ในระบบ ไม่สามารถทำการสมัครสมาชิกได้ </span>
<% end if %>
</td>
<td><label>
<input type="submit" name="Submit" value="OK" onClick="return check_form()"/>
</label>
<label>
<input type="reset" name="Submit2" value="Reset" />
</label></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------------
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'user'.
/project2/register.asp, line 31
Tag : - - - -
Date :
7 มิ.ย. 2551 00:09:05
By :
beginner
View :
1544
Reply :
0
Load balance : Server 05