0

我有一个页面,用户可以在其中选择很多复选框,然后将他们选择的每个值都插入到数据库中。我正在使用查询字符串将初始页面中的值提交到帖子页面。

这些值是用竖线分隔的,存储过程会为它们中的每一个运行。我也有一个整数提交给数据库。

几个问题 - 首先,有时我会遇到中间“无效的过程调用”错误。在其他时候,似乎我为 QueryString 提交了太多字符,因此它被截断并且并非所有值都被提交。

任何帮助表示赞赏。谢谢!

提交值的主页 - Javascript:

function submit()
{
    var n = 0;
    var stringIDs = "";

              //Number of records to submit stored in hidden text box.
    for (n=1; n<=parseInt(document.getElementById("txtResultsIndex").value); n++)
        {
            try
            {
                var cb = document.getElementById("cbSelection"+n);
                if (cb.checked) 
                    {
                        stringIDs = stringIDs + "|" + document.getElementById("linkNumber"+n).innerText;
                    }
            }

            catch(exception)
            {}
        }


window.open("submit.asp?stringIDs=" + stringIDs + "|&cboResearchedBy=" + document.getElementById("cboResearchedBy").value);

}

帖子页面经典 ASP(错误似乎源于此):

    Dim vSQLInsert, v1ID, RS, stringIDs, cboResearchedBy, CN

'GetDataConnection is included in header file.
Set CN = GetDataConnection

stringIDs = Request.QueryString("stringIDs")
cboResearchedBy = Request.QueryString("cboResearchedBy")

stringIDs = Mid(stringIDs,2,len(stringIDs)) 

Do While stringIDs <> ""
    v1ID = Mid(stringIDs,1,InStr(stringIds,"|")-1)

    'Insert data into main table.  
    vSQLInsert = "spInsert "    
    vSQLInsert = vSQLInsert & "@vResearchedBy = '" & cboResearchedBy & "',"
    vSQLInsert = vSQLInsert & "@vSequenceNumber = '" & v1ID & "'"       

    Set RS = CN.Execute (vSQLInsert)

    stringIDs = Replace(stringIDs, v1ID & "|","")
Loop
4

1 回答 1

0

删除中间功能。使用 for each 循环将值放在文本框中以提交到数组中的帖子页面。页面仍然需要一些时间来提交,但没有错误结果。

vIndex = stripquotes(Request.Form("txtIndex"))

If Request.Form("cboResearchedBy") <> "" Then vResearchedBy = stripquotes(Request.Form("cboResearchedBy")) End If

If Request.Form("txtMySeq") <> "" Then txtMySeq = Request.Form("txtMySeq") End If

vSeqArray = Split(txtMySeq, "|")

对于 vSeqArray 中的每个 vSeq

vSQLInsert = "Insert "  
vSQLInsert = vSQLInsert & "@vResearchedBy = '" & vResearchedBy & "',"
vSQLInsert = vSQLInsert & "@vSequenceNumber = '" & vSeq & "'"   

Response.Write(vSQLInsert)

Set RS = CN.Execute (vSQLInsert)

下一个

于 2013-05-02T16:36:30.083 回答