Asp classic 响应。写入字符串-ASP经典
我有一个SQL查询,它使用Do-Until循环从数据库检索值。SQLCondition在循环内的值显示正确,但如果我想在循环外显示该值,则它不起作用:Asp classic 响应。写入字符串-ASP经典,asp-classic,Asp Classic,我有一个SQL查询,它使用Do-Until循环从数据库检索值。SQLCondition在循环内的值显示正确,但如果我想在循环外显示该值,则它不起作用: If rReseller > 0 Then sql2 = "SELECT rl.countryid FROM reseller_locator rl WHERE rl.resellerid = " & rReseller & " AND rl.countryid <> '" & iCountryI
If rReseller > 0 Then
sql2 = "SELECT rl.countryid FROM reseller_locator rl WHERE rl.resellerid = " & rReseller & " AND rl.countryid <> '" & iCountryID & "'"
'response.write sql2
Set rsResellerLocator=Conn.Execute(sql2)
If not rsResellerLocator.EOF Then
do until rsResellerLocator.eof
iRCountryID = rsResellerLocator("countryid")
SQLCondition = iRCountryID & ", "
response.write SQLCondition
rsResellerLocator.movenext
loop
Else
SQLCondition = ""
End If
response.write SQLCondition
End If
如果卖方>0,则
sql2=“从经销商位置rl选择rl.countryid,其中rl.RetrierID=“&rReseller&”和rl.countryid'&ICONTRYID&'”
'response.write sql2
设置rsrelailerlocator=Conn.Execute(sql2)
如果不是rsResellerLocator.EOF,则
直到rsrelailerlocator.eof
iRCountryID=RSRelailerLocator(“countryid”)
SQLCondition=iRCountryID&“
response.write-SQLCondition
rsrelailerlocator.movenext
环
其他的
SQLCondition=“”
如果结束
response.write-SQLCondition
如果结束
循环内部的response.write显示“2,3,4,5”。但是循环外部的response.write显示“5”
如何将循环内部的值存储到字符串中,以便在查询外部使用?是否确定内部循环按预期工作?我看不出为什么它会显示“2,3,4,5”-就像你现在的代码那样,它总是只显示一个数字。试试这个: 替换
SQLCondition = iRCountryID & ", "
与
这将保存条件字符串,否则您只需保存最新的条件也可以使用此选项将需要的数据保存在字符串中
如果卖方>0,则
sql2=“从经销商位置rl选择rl.countryid,其中rl.RetrierID=“&rReseller&”和rl.countryid'&ICONTRYID&'”
'response.write sql2
设置rsrelailerlocator=Conn.Execute(sql2)
如果不是rsResellerLocator.EOF,则
直到rsrelailerlocator.eof
iRCountryID=RSRelailerLocator(“countryid”)
SQLCondition=iRCountryID&“
SQLConditionAll=“&SQLConditionAll&&&SQLConditionAll&”
response.write-SQLCondition
rsrelailerlocator.movenext
环
其他的
SQLCondition=“”
如果结束
response.write-SQLCondition
如果
SQLCondition = SQLCondition & ", " & iRCountryID