2014-12-26 74 views
1

我有一个SQL查询,它使用Do Until Loop从数据库检索值。 SQLCondition的循环中的值显示正确,但如果我想显示外循环的价值,这是行不通的:Response.Write to a String - ASP Classic

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 

的回复于从循环显示“2,3,4内,5" 。但循环外的response.write显示“5”。

如何将该值从循环内部存储到查询以外使用的字符串中?

回答

0

你确定内循环正在按照需要工作吗?我没有理由为什么它会显示“2,3,4,5” - 你的代码现在的方式,它总是只显示一个数字。试试这个:

更换

SQLCondition = iRCountryID & ", " 

随着

SQLCondition = SQLCondition & ", " & iRCountryID 

,将节省的条件下,弦,否则你只是保存最新的状态