我有一个页面,用户可以在其中选择很多复选框,然后将他们选择的每个值都插入到数据库中。我正在使用查询字符串将初始页面中的值提交到帖子页面。
这些值是用竖线分隔的,存储过程会为它们中的每一个运行。我也有一个整数提交给数据库。
几个问题 - 首先,有时我会遇到中间“无效的过程调用”错误。在其他时候,似乎我为 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