landslide
07-24-2007, 08:06 PM
I trying to figur out what is wrong with this update statment. The code does not give any errors but it doesnot update ethier. The code updates multiple records at once. Any Ideas?
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_MemphisAssessment_STRING;
Recordset1.Source = "SELECT * FROM [option] WHERE questionid = 725";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
aroption = new Array();
arquestionid = new Array();
var f=new Enumerator(Request.Form);
var el;
var start;
var len;
var idx;
for (; !f.atEnd(); f.moveNext()) {
el = f.item().toString().toLowerCase();
start = el.indexOf("_");
if(start > -1) {
start++; len = el.length - start;
idx = parseInt(el.substr(start, len));
if(!isNaN(idx)) {
if(el.indexOf("option")!=-1) aroption[idx] = Request.Form(el);
if(el.indexOf("questionid")!=-1) arquestionid[idx] = Request.Form(el);
}
}
}
for(var i=0;i<arquestionid.length;i++) {
if(aroption[i] && arquestionid[i]) {
updateDB (aroption[i], arquestionid[i]);
}
else {
Response.Write("");
}
}
function updateDB(param_option, param_questionid) {
var update = Server.CreateObject("ADODB.Command");
update.ActiveConnection = MM_MemphisAssessment_STRING;
update.CommandText = "UPDATE option SET option = '" + param_option + "' WHERE questionID = '" + param_questionID + "'";
update.CommandType = 1;
update.CommandTimeout = 0;
update.Prepared = true;
update.Execute();
update.ActiveConnection.Close();
}
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_MemphisAssessment_STRING;
Recordset1.Source = "SELECT * FROM [option] WHERE questionid = 725";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
aroption = new Array();
arquestionid = new Array();
var f=new Enumerator(Request.Form);
var el;
var start;
var len;
var idx;
for (; !f.atEnd(); f.moveNext()) {
el = f.item().toString().toLowerCase();
start = el.indexOf("_");
if(start > -1) {
start++; len = el.length - start;
idx = parseInt(el.substr(start, len));
if(!isNaN(idx)) {
if(el.indexOf("option")!=-1) aroption[idx] = Request.Form(el);
if(el.indexOf("questionid")!=-1) arquestionid[idx] = Request.Form(el);
}
}
}
for(var i=0;i<arquestionid.length;i++) {
if(aroption[i] && arquestionid[i]) {
updateDB (aroption[i], arquestionid[i]);
}
else {
Response.Write("");
}
}
function updateDB(param_option, param_questionid) {
var update = Server.CreateObject("ADODB.Command");
update.ActiveConnection = MM_MemphisAssessment_STRING;
update.CommandText = "UPDATE option SET option = '" + param_option + "' WHERE questionID = '" + param_questionID + "'";
update.CommandType = 1;
update.CommandTimeout = 0;
update.Prepared = true;
update.Execute();
update.ActiveConnection.Close();
}
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>