Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update multiple records

Status
Not open for further replies.

taoist

Programmer
Joined
Feb 1, 2006
Messages
35
Location
US
I have setup an update for my records. But for some reason
it does not want to update multiple records I'm not sure why. I have the code but its very lengthy

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../../../../../Connections/cnnDB.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form2" And CStr(Request("MM_recordId")) <> "") Then

MM_editConnection = MM_cnnDB_STRING
MM_editTable = "dbo.eval_master"
MM_editColumn = "PIDM"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "Save_Eval.asp"
MM_fieldsStr = "select|value|select2|value|select3|value"
MM_columnsStr = "GRADE|',none,''|CL_BKS|',none,''|ATT_CLASS|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("stuRun") <> "") Then
Recordset1__MMColParam = Request.QueryString("stuRun")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_cnnDB_STRING
Recordset1.Source = "SELECT * FROM dbo.eval_master WHERE CRN= '" + Replace(Recordset1__MMColParam, "'", "''") + "' AND TERM = '200630'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<style>
.odd{background-color: white;}
.even{background-color: #CCFFFF;}
.style10 { font-size: 18px;
font-weight: bold;
}
.style2 {color: #0000FF}
.style3 {color: #0000CC}
.style9 { font-size: 24px;
font-weight: bold;
}
.style12 {
color: #660000;
font-weight: bold;
}
</style>
</head>

<script language="JavaScript">
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
</script>

<script language="JavaScript">
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows.className = "even";
}else{
rows.className = "odd";
}
}
}
}

</script>


<body>
<body onload="alternate('theTable')">

<img src="../../../images/DWH_top.jpg" width="1040" height="77" /><img src="../../../images/DWH_bottom.jpg" width="1040" height="47" />
<table id="Table_01" height="969" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" valign="top" bgcolor="#FFCC00"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="1"><font face="Verdana,Arial" size="2"><font color="#000000"> Todays Date:<br />
<script language="JavaScript" type="text/javascript">
<!-- Begin
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000) // Y2K Fix
year = year + 1900;
document.write("<left>" + lmonth + " ");
document.write(date + ", " + year + "</left>");
// End -->
</script>
</font></font></font></font></font></font></font></font></font></font></td>
<td height="25" valign="top"><img src="../../../images/topleft_corner.jpg" width="27" height="21" /></td>
<td width="935" height="25"></td>
</tr>
<tr>
<td width="199" height="944" valign="top" bgcolor="#FFCC00"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="../../../images/panel_top.jpg" width="199" height="56" /></td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td valign="top" class="text">&nbsp;</td>
<td class="text">&nbsp;</td>
<td valign="top" class="text">&nbsp;</td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text">&nbsp;</td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><span class="style10"><font color="#800000">Education
Reports</font></span></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong> <a href="../FacultyRpt.asp">Faculty
Roster</a></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Course Schedule</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong><strong>Faculty Schedule</strong><a href="../../../../scholarships.shtml"></a></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td class="text">&nbsp;</td>
<td valign="top" class="text"><strong><strong>Class Roster</strong><a href="../../../../scholarships.shtml"></a><a href="../../../../scholarships.shtml"><br />
</a></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Full Classes<a href="../../../../scholarships.shtml"></a></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Less Than 10 in Class</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Class Enrollment Stat</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Add Query</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Add Query</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Add Query</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Add Query</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text">&nbsp;</td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text">&nbsp;</td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong><a href="Eval_login.asp">Academic
Evaluation</a></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong> <strong>Add Query</strong></strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text"><strong><img src="../../../images/button2.jpg" width="10" height="10" /></strong></td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text"><strong>Add Query</strong></td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" bgcolor="#CC9900" class="text">&nbsp;</td>
<td width="10" bgcolor="#CC9900" class="text">&nbsp;</td>
<td valign="top" bgcolor="#CC9900" class="textwht">&nbsp;</td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text">&nbsp;</td>
<td width="10" class="text">&nbsp;</td>
<td valign="top" class="text">&nbsp;</td>
<td background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
<tr>
<td width="20" background="../../../../images/panel_edge_l.jpg"><img src="../../../images/panel_edge_l.jpg" width="20" height="20" /></td>
<td width="10" valign="top" class="text">&nbsp;</td>
<td width="10" class="text">&nbsp;</td>
<td width="100%" valign="top" class="text">&nbsp;</td>
<td width="15" background="../../../../images/panel_edge_r.jpg"><img src="../../../images/panel_edge_r.jpg" width="15" height="20" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="../../../images/panel_bottom.jpg" width="199" height="183" /></td>
</tr>
</table></td>
<td width="27" valign="top">&nbsp;</td>
<td width="935" valign="top"><table width="930" border="0" cellpadding="8" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td height="99" colspan="3" valign="top"><p align="center"><span style="margin-top: 0;"><span class="text"><font color="#800000" size="4"><a href="../../../Education.asp">General</a> </font></span><font size="4">| <span class="text"> <a href="../../../ArtScience.asp">Arts
and Science</a></span> | <span class="text"><a href="../../../Business.asp">Business</a> </span>|<strong> <span class="text"><a href="../../../Education.asp">Education</a></span></strong><span class="text"> | <a href="../../../CSUWest.asp">CSU - West</a></span></font></span></p>
<hr size="1" noshade="noshade" color="#000000" />
<p align="left" class="text" style="margin-top: 0;"><b><span class="style2"><span class="style3"><font class="headline">Information Technology
&amp; Services &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span></span></b><span class="style2"><span class="style3"><font class="headline"><span class="style9">Academic Evaluation - Form </span></font></span></span><a href="../../../remind.shtml"><br />
</a></p></td>
</tr>
<tr>
<td height="30" colspan="3" valign="top" bgcolor="#FFCC00"><form action="" method="get" name="form1" id="form1">
Course Number:
<input name="stuRun" type="text" id="stuRun" />
<input type="submit" name="Submit2" value="Click &amp; Run" />
</form></td>
</tr>
<tr>
<td width="604" height="246" align="left" valign="top"><span class="style11">
<table width="566" border="0">
<tr>
<td width="556"><strong>Professor: </strong><%=(Recordset1.Fields.Item("INSTRUCTOR_FIRST_NAME").Value)%><%=(Recordset1.Fields.Item("INSTRUCTOR_LAST_NAME").Value)%></td>
</tr>
<tr>
<td><strong>Term: </strong><%=(Recordset1.Fields.Item("TERM").Value)%>, </td>
</tr>
<tr>
<td><strong>Course Number: </strong><%=(Recordset1.Fields.Item("CRN").Value)%> <strong>Subject: </strong><%=(Recordset1.Fields.Item("SUBJ_DESC").Value)%></td>
</tr>
</table>
<form id="form2" name="form2" method="POST" action="<%=MM_editAction%>">
<table width="428" border="1" id="theTable">
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="131"><%=(Recordset1.Fields.Item("FIRST").Value)%> &nbsp; <%=(Recordset1.Fields.Item("LAST").Value)%></td>
<td width="45" align="center" valign="middle">Grade
<label>
<select name="select">
<option>*</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>F</option>
<option>I</option>
</select>
</label></td>
<td width="85" align="center" valign="middle">Assignments
<label><br/>
<select name="select2">
<option>*</option>
<option>Yes</option>
<option>No</option>
</select>
</label></td>
<td width="75" align="center" valign="middle">Attendence
<label>
<select name="select3">
<option>*</option>
<option>Yes</option>
<option>No</option>
</select>
</label>
<div align="center"></div></td>
<td width="58" align="center" valign="middle">Tutor
<label>
<select name="select4">
<option>*</option>
<option>Yes</option>
<option>No</option>
</select>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>

<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("PIDM").Value %>">
</form>
<p>&nbsp;</p>
<p>&nbsp;</p></td>
<td width="16" align="left" valign="top">&nbsp;</td>
<td width="262" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
<td height="246" colspan="3" align="left" valign="top">&nbsp;</td>
</tr>
</table>
<label></label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
 
does anyone know how to do this
 

:--------------------------------------------------------------------------:
fugitive.gif

All around in my home town,
They tryin' to track me down...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top