Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP List boxes

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
Hi,

I am trying to create a list box with information generated from a database. I have done this before but the problem is that I would like to select certain information to be in the list box. For example I have a faults table; each fault has a status assigned to them and I would like to select all the faults that are unassigned to be in the list box. Do I have to use an SQL statement in this?? Any help would be greatly appreciated!!
 
Right, something like:
Code:
strSQL = "SELECT fault_name FROM faults WHERE fault_status = 'Assigned'"

Take Care,
Mike
 
Hi Mike
Thank you for your quick response. That may only be part of the solution as I need to include the result of that SQL statement in to a list box. That is the part I am getting stuck on.


Sunil606
 
Oh, the other part is easy:
Code:
<%
strSQL = &quot;SELECT fault_name, fault_id FROM faults WHERE fault_status = 'Assigned'&quot;
'make database connection and populate resultset objRS
%>
<select name=&quot;selTest&quot; id=&quot;selTest&quot;>
    <option></option>
<%
While (Not objRS.End)
%>
    <option value=&quot;<%= objRS(&quot;fault_id&quot;) %>&quot;><%= objRS(&quot;fault_name&quot;) %></option>
<%
    objRS.MoveNext
Wend
%>
</select>
Set objRS = Nothing
' close connection and set it to nothing

That should pretty much do it. All you need to do is replace the comments with the appropriate code.

Take Care,
Mike
 
Hi
I am going to try that out and will let you know if it works. Once again thank you for help and quick response.

Sunil606
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top