 |
|
กรอกข้อมูลแล้ว มันขึ้น error อย่างนี้อะครับ The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. |
|
 |
|
|
 |
 |
|
Code
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
Code (PHP)
<% Option Explicit %>
<html>
<head>
<title>บันทึกเรียบร้อยแล้ว</title>
<meta name="generator" content="Namo WebEditor">
</head>
<body>
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("plan_follow.mdb"),"" , ""
strSQL = "UPDATE october SET "
strSQL = strSQL&" [number] = '"&Request.Form("txtnumb")&"' "
strSQL = strSQL&",project = '"&Request.Form("txtproject")&"' "
strSQL = strSQL&",kpi = '"&Request.Form("txtkpi")&"' "
strSQL = strSQL&",type_kpi = '"&Request.Form("txttype_kpi")&"' "
strSQL = strSQL&",goal = '"&Request.Form("txtgoal")&"' "
strSQL = strSQL&",done_job = '"&Request.Form("done_job")&"' "
strSQL = strSQL&"WHERE [number] = '"&Request.QueryString("numb")&"' "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End IF
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
<br>
<input type="button" onClick="window.location='aspaccesseditrecordlist.asp'" value="กลับสู่หน้าหลัก>>">
</body>
</html>
คุณ mr. win ช่วยด้วยครับ
Tag : ASP, Ms Access
|
|
 |
 |
 |
 |
Date :
2010-12-15 10:27:46 |
By :
pong_1999 |
View :
6660 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ฟิวด์ [number] ของคุณเป็น primary key ครับ แล้วคุณจะทำการอัพเดทฟิวด์นี้ด้วยค่าที่มันซ้ำกับข้อมูลที่มีอยู่แล้วในฐานข้อมูล ก็คือ Request.Form("txtnumb") ที่คุณส่งไป update นั่นซ้ำในฐานข้อมูลนั่นเองครับลองเช็คดูดีๆครับ ถ้าไม่จำเป็นต้องเปลี่ยนแปลงค่าฟิวด์นี้ก็ใช้แบบนี้ดูครับ
Code (ASP)
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("plan_follow.mdb"),"" , ""
strSQL = "UPDATE october SET "
strSQL = strSQL&" project = '"&Request.Form("txtproject")&"' "
strSQL = strSQL&",kpi = '"&Request.Form("txtkpi")&"' "
strSQL = strSQL&",type_kpi = '"&Request.Form("txttype_kpi")&"' "
strSQL = strSQL&",goal = '"&Request.Form("txtgoal")&"' "
strSQL = strSQL&",done_job = '"&Request.Form("done_job")&"' "
strSQL = strSQL&"WHERE [number] = '"&Request.QueryString("numb")&"' "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End IF
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
แต่ถ้าจำเป็นต้องมีการเปลี่ยนแปลงฟิวด์ [number] ของท่านให้ท่าน select ข้อมูลดูก่อนว่าฟิวด์ [number] มีค่า Request.Form("txtnumb") ถ้าไม่มีค่อย Insert/Update ข้อมูลเข้าไปครับ
Code (ASP)
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("plan_follow.mdb"),"" , ""
Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open "Select [number] FROM october WHERE [number] = '"&Request.QueryString("txtnumb")&"' ",Conn,1,1
if RS.Recordcount=0 then
'ไม่มีข้อมูลที่ [number] = Request.QueryString("txtnumb")
strSQL = "UPDATE october SET "
strSQL = strSQL&" [number] = '"&Request.Form("txtnumb")&"' "
strSQL = strSQL&",project = '"&Request.Form("txtproject")&"' "
strSQL = strSQL&",kpi = '"&Request.Form("txtkpi")&"' "
strSQL = strSQL&",type_kpi = '"&Request.Form("txttype_kpi")&"' "
strSQL = strSQL&",goal = '"&Request.Form("txtgoal")&"' "
strSQL = strSQL&",done_job = '"&Request.Form("done_job")&"' "
strSQL = strSQL&"WHERE [number] = '"&Request.QueryString("numb")&"' "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End IF
end if
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
|
 |
 |
 |
 |
Date :
2010-12-15 11:19:32 |
By :
wad |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือว่า ผมใช้ ตามที่คุณแนะนำแล้วนะครับ
แต่พอผมได้ดำเนินการแก้ไขข้อมูล แล้วมันผ่านนะครับ แต่พอผมให้มันแสดงอีกครับ ข้อมูลก็ไม่เปลี่ยนอ่ะครับ
|
 |
 |
 |
 |
Date :
2010-12-15 13:57:17 |
By :
pong_1999 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ของเราเป็นโค๊ดอีกแบบ ลองหาข้อมูลเหมือนกัน
แต่สุดท้าย ลืม Where ในส่วนของ Update
ลองดูนะคะ (ไม่รู้เหมือนกันหรือป่าว)
|
 |
 |
 |
 |
Date :
2013-02-01 10:10:14 |
By :
เมย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|