0

値がデータベースから取得されるフォームがあり、すべての入力フィールドには独自の名前があり、ループされています。データをフォームから送信すると、各行の各セルのループと同じように挿入されます:(

これがスクリーンショットです適切に説明するため

ここに画像の説明を入力

これは、そこからレコードをループしたフォームです。

<%
While Not RStmtbl.EOF
%>
<tr>
<td><input type="text" value="<% Response.Write(Rstmtbl("tdate"))%>" name="tdate_insert" readonly /></td>
<td><input type="text" value="<% Response.Write(Rstmtbl("day"))%>" name="day_insert" readonly /></td>
<td><input type="text" value="<% Response.Write(Rstmtbl("class"))%>" name="class_insert" readonly /></td>
<td><input type="text" value="<% Response.Write(Rstmtbl("pno"))%>" name="pno_insert" readonly /></td>
<td><input type="text" value="<% Response.Write(Rstmtbl("subject"))%>" name="subject_insert" readonly /></td>
<td><input type="text" value="<% Response.Write(Rstmtbl("teacher"))%>" name="teacher_insert" readonly /></td>
<td>
<select name="status_insert">
<option selected>Choose Status</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<input type="hidden" value="<% Response.Write(formno) %>" name="uid_insert">
<input type="hidden" value="<% Response.Write(Now) %>" name="sdate_insert">
</td>
</tr>
<%
RStmtbl.Movenext
Wend
%>

挿入コードはこちら

<%
if request.Form("TcfRecord")="Insert" then
Set InsCom=Server.CreateObject("ADODB.Command")
InsCom.ActiveConnection=objConn

InsTD = Trim(request.Form("tdate_insert"))
InsTD = replace(InsTD,"'","''")

InsTD2 = Trim(request.Form("day_insert"))
InsTD2 = replace(InsTD2,"'","''")

InsCL = Trim(request.Form("class_insert"))
InsCL = replace(InsCL,"'","''")

InsPI = Trim(request.Form("pno_insert"))
InsPI = replace(InsPI,"'","''")

InsSBI = Trim(request.Form("subject_insert"))
InsSBI = replace(InsSBI,"'","''")

InsTI = Trim(request.Form("teacher_insert"))
InsTI = replace(InsTI,"'","''")

InsSI = Trim(request.Form("status_insert"))
InsSI = replace(InsSI,"'","''")

InsUI = Trim(request.Form("uid_insert"))
InsUI = replace(InsUI,"'","''")

InsDI = Trim(request.Form("sdate_insert"))
InsDI = replace(InsDI,"'","''")

For Each item in Request.Form
InsCom.CommandText = "Insert into time_table_status(tdate, [day], [class], pno, subject, teacher, status, uid, submit_date)Values(?,?,?,?,?,?,?,?,?)"
InsCom.Parameters.Append InsCom.CreateParameter("@tdate_insert", adVarChar, adParamInput, 255, InsTD)
InsCom.Parameters.Append InsCom.CreateParameter("@day_insert", adVarChar, adParamInput, 255, InsTD2)
InsCom.Parameters.Append InsCom.CreateParameter("@class_insert", adVarChar, adParamInput, 255, InsCL)
InsCom.Parameters.Append InsCom.CreateParameter("@pno_insert", adVarChar, adParamInput, 255, InsPI)
InsCom.Parameters.Append InsCom.CreateParameter("@subject_insert", adVarChar, adParamInput, 255, InsSBI)
InsCom.Parameters.Append InsCom.CreateParameter("@teacher_insert", adVarChar, adParamInput, 255, InsTI)
InsCom.Parameters.Append InsCom.CreateParameter("@status_insert", adVarChar, adParamInput, 255, InsSI)
InsCom.Parameters.Append InsCom.CreateParameter("@uid_insert", adVarChar, adParamInput, 255, InsUI)
InsCom.Parameters.Append InsCom.CreateParameter("@sdate_insert", adVarChar, adParamInput, 255, InsDI)

InsCom.Execute

Next

end if
%>

各行の各セルに 1 つの値が必要です。エラーを特定するのを手伝ってください...

4

1 に答える 1