0

我有一个表单,其中包含不同数量的“答案”字段。所以我尝试这样构建我的数组:

        match = "found"
        form_counter = 1
        i=0
        DIM pollanswer()
        do while match = "found"
        pollanswer(i) = lr_request_collection_dict("poll_answer" & form_counter)
            if pollanswer(i) = "" then
            match ="notfound"
            end if
        form_counter=form_counter+1
        i=i+1
        loop

稍后在我的代码中,我正在获取这些值并希望将它们插入到我的数据库中,但这是我卡住的地方,因为我确实需要自己插入第一个值,然后循环遍历其余的值。

thisQuery = "insert into survey_2_surveyquestionanswers (surveyquestionanswer_surveyquestionid, "&_
            "surveyquestionanswer_answer, surveyquestionanswer_answerlabel, surveyquestionanswer_order) "&_
            "select @@identity, "& SQLQuote(pollanswer(0)) &", "& SQLQuote(pollanswer(0)) &", 1 "&_
            icount = 1
            ecount = 2
            for each arrValue in pollanswer
            "union select @@identity, "& SQLQuote(pollanswer) &", "& SQLQuote(pollanswer) &", "& SQLInt(ecount)
            ecount=ecount+1
            next
            ";"
            set thisRS = dbAccessObj.DirectQuery("live", thisQuery)

任何帮助将不胜感激。

4

1 回答 1

0

好吧,您似乎使用“for each”方法两次插入第一个条目。

您可以使用索引形式:

for a_index = 1 to Ubound(pollanswer)
    arrValue = pollanswer(a_index)
    ...
next

这只是省略了第一个数组元素。

于 2012-05-16T14:34:31.030 回答