hogwild76
asked on
I'm getting an "Optimistic concurrency check failed..." error.
I'm getting the following error on one field of a form. If that field is not modified, I don't get the error, but if it is, the data is not processed.
"Optimistic concurrency check failed. The row was modified outside of this cursor."
I'm running a SQL Server backend, and the code works with an Access backend. Can someone help me figure this one out?
Here's my code: (The field that's erroring out is between the hypenated lines at the bottom.)
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
Dim adoCon
Dim rsTask
Dim strSQL
Dim lngRecordNo
'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString(" ID"))
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB .Connectio n")
adoCon.open "PROVIDER=SQLOLEDB;DATA SOURCE=***;UID=intranet_us er;PWD=*** ;DATABASE= intranet"
'Create an ADO recordset object
Set rsTask = Server.CreateObject("ADODB .Recordset ")
'Initialize the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM internal_tracking_system WHERE its_number=" & lngRecordNo
'Open the recordset with the SQL query
rsTask.Open strSQL, adoCon
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ITS - Edit Task</title>
<link rel="stylesheet" type="text/css" href="/ids/intranet.css" />
<!--Date Input Mask-->
<!--#include virtual="/ids/scripts/date _mask.js"- ->
<!--End of Date Input Mask-->
<script type="text/javascript">
function validateForm(form) {
if (form.reply_date.value == "") {
alert("You must provide the reply date.");
form.reply_date.focus( );
return false;
}
}
</script>
</head>
<body>
<!--#include virtual="/ids/includes/top .htm"-->
<!--Content-->
<div style="padding-top: 5px">
<table width="100%" style="background-color: #000080" cellpadding="5" cellspacing="0">
<tr>
<td width="125px"><a href="/ids/pages/administr ator/its/a dd_task.as p" style="font-size: 11px; color: #FFFFFF; text-decoration: none">Create a New Task</a></td>
<td width="100px"><a href="/ids/pages/administr ator/its/a ll_tasks.a sp" style="font-size: 11px; color: #FFFFFF; text-decoration: none">View All Tasks</a></td>
<td width="100px"><a href="/ids/pages/administr ator/its/o pen_tasks. asp" style="font-size: 11px; color: #FFFFFF; text-decoration: none">View Open Tasks</a></td>
<td width="55%"> </td>
</tr>
</table>
<br />
<form name="add" method="post" action="update_record.asp" >
<table align="center" width="55%" class="securitytable">
<tr valign="top">
<td><img src="/ids/graphics/swpa_ve rtical_log o.jpg" border="0" alt="logo" /></td>
<td><p style="font-size: 28px; font-weight: bold">Internal Tracking System</p><br /><hr style="color: #000080" /><p style="font-size: 14px; font-weight: bold">Office of the Administrator</p></td>
</tr>
<tr><td colspan="2"> </td></t r>
<tr>
<td colspan="2">
<table align="center" width="100%">
<tr>
<td class="input_text">ITS Number: </td>
<td><input type="text" readonly="readonly" name="ID" value="<% = rsTask("its_number") %>" class="data" style="background-color: #99CCCC; border: 0" /></tr>
</tr>
<tr>
<td class="input_text" width="27%">Date Received:</td>
<td><input class="input" size="15" maxlength="10" type="text" name="date_received" onfocus="javascript:vDateT ype='1'" onkeyup="DateFormat(this,t his.value, event,fals e,'1')" onblur="DateFormat(this,th is.value,e vent,true, '1')" value="<% = rsTask("date_received") %>" /></td>
<td class="input_text" width="20%">Received Via:</td>
<td align="center"><select name="method_received" class="input">
<option><% = rsTask("method_received") %></option>
<option>Email</option>
<option>Fax</option>
<option>Postal Mail</option>
</select></td>
</tr>
<tr>
<td class="input_text" width="30%">From:</td>
<td colspan="3"><input type="text" size="60%" name="received_from" maxlength="50" class="input" value="<% = rsTask("received_from") %>" /></td>
</tr>
<tr>
<td class="input_text" width="30%">Subject:</td>
<td colspan="3"><input type="text" size="60%" name="subject" maxlength="255" class="input" value="<% = rsTask("subject") %>" /></td>
</tr>
<tr>
<td class="input_text" width="30%">Responsible Party:</td>
<td colspan="3"><input type="text" size="60%" name="responsible_party" maxlength="50" class="input" value="<% = rsTask("responsible_party" ) %>" /></td>
</tr>
<tr>
<td class="input_text" width="30%">Response Due Date:</td>
<td><input class="input" size="15" maxlength="10" type="text" name="due_date" onfocus="javascript:vDateT ype='1'" onkeyup="DateFormat(this,t his.value, event,fals e,'1')" onblur="DateFormat(this,th is.value,e vent,true, '1')" value="<% = rsTask("due_date") %>" /></td>
<td class="input_text" width="20%">Date Replied:</td>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -
<td><input class="input" size="15" maxlength="10" type="text" name="reply_date" value="No Reply Yet" onfocus="javascript:vDateT ype='1'" onkeyup="DateFormat(this,t his.value, event,fals e,'1')" onblur="DateFormat(this,th is.value,e vent,true, '1')" /></td>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -
</tr>
<tr>
<td class="input_text" width="30%" colspan="2">Details:</td>
</tr>
<tr>
<td colspan="4"><textarea name="details" class="ta" cols="98%" rows="10"><% = rsTask("details") %></textarea>
</tr>
<tr>
<td align="center" colspan="4"><input type="submit" name="Submit" value="Update Task" class="submit" /></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<%
'Reset server objects
rsTask.Close
Set rsTask = Nothing
Set adoCon = Nothing
%>
"Optimistic concurrency check failed. The row was modified outside of this cursor."
I'm running a SQL Server backend, and the code works with an Access backend. Can someone help me figure this one out?
Here's my code: (The field that's erroring out is between the hypenated lines at the bottom.)
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
Dim adoCon
Dim rsTask
Dim strSQL
Dim lngRecordNo
'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB
adoCon.open "PROVIDER=SQLOLEDB;DATA SOURCE=***;UID=intranet_us
'Create an ADO recordset object
Set rsTask = Server.CreateObject("ADODB
'Initialize the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM internal_tracking_system WHERE its_number=" & lngRecordNo
'Open the recordset with the SQL query
rsTask.Open strSQL, adoCon
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ITS - Edit Task</title>
<link rel="stylesheet" type="text/css" href="/ids/intranet.css" />
<!--Date Input Mask-->
<!--#include virtual="/ids/scripts/date
<!--End of Date Input Mask-->
<script type="text/javascript">
function validateForm(form) {
if (form.reply_date.value == "") {
alert("You must provide the reply date.");
form.reply_date.focus( );
return false;
}
}
</script>
</head>
<body>
<!--#include virtual="/ids/includes/top
<!--Content-->
<div style="padding-top: 5px">
<table width="100%" style="background-color: #000080" cellpadding="5" cellspacing="0">
<tr>
<td width="125px"><a href="/ids/pages/administr
<td width="100px"><a href="/ids/pages/administr
<td width="100px"><a href="/ids/pages/administr
<td width="55%"> </td>
</tr>
</table>
<br />
<form name="add" method="post" action="update_record.asp"
<table align="center" width="55%" class="securitytable">
<tr valign="top">
<td><img src="/ids/graphics/swpa_ve
<td><p style="font-size: 28px; font-weight: bold">Internal Tracking System</p><br /><hr style="color: #000080" /><p style="font-size: 14px; font-weight: bold">Office of the Administrator</p></td>
</tr>
<tr><td colspan="2"> </td></t
<tr>
<td colspan="2">
<table align="center" width="100%">
<tr>
<td class="input_text">ITS Number: </td>
<td><input type="text" readonly="readonly" name="ID" value="<% = rsTask("its_number") %>" class="data" style="background-color: #99CCCC; border: 0" /></tr>
</tr>
<tr>
<td class="input_text" width="27%">Date Received:</td>
<td><input class="input" size="15" maxlength="10" type="text" name="date_received" onfocus="javascript:vDateT
<td class="input_text" width="20%">Received Via:</td>
<td align="center"><select name="method_received" class="input">
<option><% = rsTask("method_received") %></option>
<option>Email</option>
<option>Fax</option>
<option>Postal Mail</option>
</select></td>
</tr>
<tr>
<td class="input_text" width="30%">From:</td>
<td colspan="3"><input type="text" size="60%" name="received_from" maxlength="50" class="input" value="<% = rsTask("received_from") %>" /></td>
</tr>
<tr>
<td class="input_text" width="30%">Subject:</td>
<td colspan="3"><input type="text" size="60%" name="subject" maxlength="255" class="input" value="<% = rsTask("subject") %>" /></td>
</tr>
<tr>
<td class="input_text" width="30%">Responsible Party:</td>
<td colspan="3"><input type="text" size="60%" name="responsible_party" maxlength="50" class="input" value="<% = rsTask("responsible_party"
</tr>
<tr>
<td class="input_text" width="30%">Response Due Date:</td>
<td><input class="input" size="15" maxlength="10" type="text" name="due_date" onfocus="javascript:vDateT
<td class="input_text" width="20%">Date Replied:</td>
--------------------------
<td><input class="input" size="15" maxlength="10" type="text" name="reply_date" value="No Reply Yet" onfocus="javascript:vDateT
--------------------------
</tr>
<tr>
<td class="input_text" width="30%" colspan="2">Details:</td>
</tr>
<tr>
<td colspan="4"><textarea name="details" class="ta" cols="98%" rows="10"><% = rsTask("details") %></textarea>
</tr>
<tr>
<td align="center" colspan="4"><input type="submit" name="Submit" value="Update Task" class="submit" /></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<%
'Reset server objects
rsTask.Close
Set rsTask = Nothing
Set adoCon = Nothing
%>
ASKER
Disregard this question. I found the answer.
The problem was my
IF rsTask("reply_date")<>"No Reply Yet" THEN
adoCon.execute("update internal_tracking_system set status = 'Complete' where its_number="& rsTask("its_number") )
END IF
statement occuring before my RS update. I moved it to after it, and it works fine.
The problem was my
IF rsTask("reply_date")<>"No Reply Yet" THEN
adoCon.execute("update internal_tracking_system set status = 'Complete' where its_number="& rsTask("its_number") )
END IF
statement occuring before my RS update. I moved it to after it, and it works fine.
You could post a question at "Community Support" and request that this question be deleted and refund u the points.
https://www.experts-exchange.com/Community_Support/
:) SD
https://www.experts-exchange.com/Community_Support/
:) SD
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<!--This file updates the selected record in the Internal Task System.-->
<%
Dim adoCon
Dim rsTask
Dim strSQL
Dim lngRecordNo
Dim rsTask1
Dim strSQL1
'Read in the record number to be updated
lngRecordNo = CLng(Request.Form("ID"))
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB
'DSN-less connection
adoCon.open "PROVIDER=SQLOLEDB;DATA SOURCE=***;UID=intranet_us
'Create an ADO recordset object
Set rsTask = Server.CreateObject("ADODB
strSQL = "SELECT * FROM internal_tracking_system WHERE its_number=" & lngRecordNo
rsTask.CursorType = 2
rsTask.LockType = 3
rsTask.Open strSQL, adoCon
rsTask.Fields("date_receiv
rsTask.Fields("method_rece
rsTask.Fields("received_fr
rsTask.Fields("subject") = Request.Form("subject")
rsTask.Fields("responsible
rsTask.Fields("due_date") = Request.Form("due_date")
rsTask.Fields("reply_date"
rsTask.Fields("details") = Request.Form("details")
IF rsTask("reply_date")<>"No Reply Yet" THEN
adoCon.execute("update internal_tracking_system set status = 'Complete' where its_number="& rsTask("its_number") )
END IF
'Write the updated recordset to the database
rsTask.Update
'Reset server objects
rsTask.Close
Set rsTask = Nothing
'Create an ADO recordset object
Set rsTask1 = Server.CreateObject("ADODB
strSQL1 = "SELECT * FROM internal_tracking_system WHERE its_number=" & lngRecordNo
'Open the recordset with the SQL query
rsTask1.Open strSQL1, adoCon
%>
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Internal Tracking System</title>
<link rel="stylesheet" type="text/css" href="/ids/intranet.css" />
</head>
<body>
<!--#include virtual="/ids/includes/top
<!--Content-->
<div style="padding-top: 5px">
<table width="100%" style="background-color: #000080" cellpadding="5" cellspacing="0">
<tr>
<td style="width: 125px"><a href="/ids/pages/administr
<td style="width: 100px"><a href="/ids/pages/administr
<td style="width: 100px"><a href="/ids/pages/administr
<td style="width: 55%"> </td>
</tr>
</table>
<br />
<!--#include virtual="/ids/pages/admini
</div>
</body>
</html>
<%
'Reset server objects
rsTask1.Close
Set rsTask1 = Nothing
Set adoCon = Nothing
%>