Hi,
I'm using dreamweaver repeat region server behaviour to populate a table/form on a webpage. I now need to insert all the values into a database using dreamweaver and repeat region server behavior. If I remove the behaviour used to populate the table/form, it will successsfully write 1 record. However I can't get it to insert multiple records. Help!!!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn_3_coast.asp" -->
<%
Dim MM_editAction
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
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form3") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_conn_3_coast_STRING
MM_editCmd.CommandText = "INSERT INTO studentResults (enrolno, taskid, [result]) VALUES (?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 10, Request.Form("enrolno")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("taskid"), Request.Form("taskid"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("mark"), Request.Form("mark"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "TaskGrades.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<%
Dim rs_marks__MMColParam
rs_marks__MMColParam = "1"
If (Request.Form("taskID") <> "") Then
rs_marks__MMColParam = Request.Form("taskID")
End If
%>
<%
Dim rs_marks
Dim rs_marks_cmd
Dim rs_marks_numRows
Set rs_marks_cmd = Server.CreateObject ("ADODB.Command")
rs_marks_cmd.ActiveConnection = MM_conn_3_coast_STRING
rs_marks_cmd.CommandText = "SELECT courses.classcode, studentdetails.enrolno, studentdetails.surname, studentdetails.forename, studentdetails.tutorgroup, coursetasks.taskid, coursetasks.subject, coursetasks.tasktype, coursetasks.assessmentTitle, coursetasks.date, coursetasks.maxmark FROM (courses INNER JOIN coursetasks ON courses.classcode = coursetasks.classcode) INNER JOIN (studentdetails INNER JOIN Performancetodate ON studentdetails.enrolno = Performancetodate.enrolno) ON courses.classcode = Performancetodate.courseid WHERE (((coursetasks.taskid)=?));"
rs_marks_cmd.Prepared = true
rs_marks_cmd.Parameters.Append rs_marks_cmd.CreateParameter("param1", 5, 1, -1, rs_marks__MMColParam) ' adDouble
Set rs_marks = rs_marks_cmd.Execute
rs_marks_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rs_marks_numRows = rs_marks_numRows + Repeat1__numRows
%>
<table align="center" border="1">
<tr>
<td align="left" width="50%">classcode</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">enrolno</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">surname</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">forename</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">tutorgroup</td>
<td align="left" width="50%"></td>
</tr>
<tr>
<td align="left" width="50%">taskid</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">subject</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">tasktype</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">assessmentTitle</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">date</td>
<td align="left" width="50%"> </td>
</tr>
<tr>
<td align="left" width="50%">maxmark</td>
<td align="left" width="50%"> </td>
</tr>
</table>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<h1>Coast@JCC</h1>
<h1>Add Marks</h1>
<form id="form1" name="form1" method="post" action="">
<table width="355" border="1">
<tr>
<td width="82">Class Code</td>
<td width="48"><%=(rs_marks.Fields.Item("classcode").Value)%></td>
<td width="64">Task Title</td>
<td width="133"><%=(rs_marks.Fields.Item("assessmentTitle").Value)%></td>
</tr>
</table>
</form>
<form id="form2" name="form2" method="post" action="">
<table width="980" border="1">
<tr>
<td width="58">Unit Number</td>
<td width="233"> </td>
<td width="207">Date</td>
<td width="143"><%=(rs_marks.Fields.Item("date").Value)%></td>
<td width="161">Maximum Mark</td>
<td width="138"><%=(rs_marks.Fields.Item("maxmark").Value)%></td>
</tr>
</table>
</form>
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form3" name="form3">
<table width="982" border="1">
<tr>
<th width="56">Surname</th>
<th width="64">Forename</th>
<th width="4">Ad Number</th>
<th width="4">Tutor</th>
<th width="4">Task ID</th>
<th width="4">Mark</th>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_marks.EOF))
%>
<tr>
<td><%=(rs_marks.Fields.Item("surname").Value)%></td>
<td><%=(rs_marks.Fields.Item("forename").Value)%></td>
<td><input name="enrolno" type="text" id="enrolno" value="<%=(rs_marks.Fields.Item("enrolno").Value)%>" maxlength="10" /></td>
<td><%=(rs_marks.Fields.Item("tutorgroup").Value)%></td>
<td><input name="taskid" type="text" id="taskid" value="<%=(rs_marks.Fields.Item("taskid").Value)%>" /></td>
<td><input name="mark" type="text" id="mark" size="6" /></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_marks.MoveNext()
Wend
%>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form3" />
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<%
rs_marks.Close()
Set rs_marks = Nothing
%>