将两个迭代值添加到更新查询 asp-classic

adding two iterative values into an update query asp-classic

我确定我这里的错误很简单

我的 sqlDB 中有一个二维数组在单个列上

myList = rs.GetRows()

我的 html 页面包含基于数组长度的输入。 :

<input type="number" name="actual"> 

现在,我要做的是构建一个唯一的 SQL 更新查询,其中实际列与 unique_id 列匹配

假设我的列表中只有两个变量。

for each x in my list
 response.write(x)
1,
2

并且只有两个输入,因为输入是由唯一 ID 生成的

for inputs in response.form("actual")
 response.write(inputs)
55,
66

现在,我想结合这些来构建我的更新查询。

我试过写一个双 for 循环,但这会为输入的每个实例生成一个 ID,因此创建 4 个变量而不是 2 个

 Unique ID, Input
    1 : 55
    1 : 66
    2 : 55
    2 : 66

我想要的是

1 : 55
2 : 66

有人能帮忙吗?我已经在这几个小时了。我不是编码员,也不是技术背景,而且我对遗留系统和流程深有体会。

我确定字典是可行的方法,因此我可以生成一对一的关系,但我不知道如何将我的输入转换为列表,然后将它们传递给字典。

html 生成我的 table 的代码:

  <div class="container">
              <table id="table" class="table">
                <thead class="thead-dark">
                  <tr>
                  <th scope="col" data-field="article">Unique ID</th>
                  <th scope="col" data-field="item">Item Name</th>
                  <th scope="col" data-field="quant">Quantity</th>
                  <th scope="col" data-field="act">Actual</th>
              </tr>
              </tr>
            </thead>
            </div>

           <%
           While not grs.eof
          %>
            <tr>
                <th><%=grs.fields("UniqueID")%></th>
                <th><%=grs.fields("itemName")%></th>
                <th><%=grs.fields("quant")%></th>
                <input type="number" class="form-control" id="actual" placeholder="<%=grs.fields("actual")%>" name="Actual">

            <%

            grs.movenext
            Wend
SQL update query goes here %>

好的,这里有小东西:

你的 id 不能每行都一样,所以做类似 id=actual_<%=grs.fields("UniqueID")%>

你可以试试这个:

<input type="number" class="form-control" id="actual_<%=grs.fields("UniqueID")%>" placeholder="<%=grs.fields("actual")%>" name="actual_<%=grs.fields("UniqueID")%>">

然后在你的循环中:

for each inputs in request.form
   if left(inputs, 7) = "actual_" then
      myId = mid(inputs, 8)
      myValue = request.form("actual_" & myId)

      <your sql statement here>
   end if
next

(你必须添加一些东西来检查你正在检查的输入的名称至少有 7 个字符长,否则你会得到一个错误)