I am very new to VB, and was asked to look at a problem with values not populating a drop down menu. The code below populates the first drop down menu, but the second drop down menu is blank. If I copy and paste the sql execute to recreate the rs variable, my drop down menus will populate.
I’m sure I’m not preserving the variable correctly, but like I said, I am very new to VB.
<%
sql = ""
sql = sql & "EXECUTE dbo.web_FetchPlans @ID = " & ID
Set rs = objConn.execute(sql)
%>
<select name="first" type="text" ">
<option value="">Please select ...</option>
<% if not rs.eof then
rs.moveFirst()
do while not rs.EOF
%>
<%
if not rs.eof then
rs.moveFirst()
do while not rs.EOF
%>
<option value="<%=rs("productCode")%>"><%=rs("productName")%></option>
<%
rs.moveNext()
loop
end if
%>
</select>
So when I go to create my second drop down box using the same code, to loop through rs, my options are empty.
The problem may lie in this code –
By the time you reach your second drop down list the
rs.EOFcondition will be true so thers.moveFirst()won’t occur and the loop will end immediately.