Reputation: 27
i have this code for populating combo boxes for the page the admin staff, allowing them to search for courses that have been booked in accordance to their skill level, however seen as it is for my A2 computing i decided to populate the combo box with the values from the table, sadly, as expected, it shows reoccurences of the same value inputted on the table, so how do I adapt my current code for this to essentially do the equivalent of a SELECT DISTINCT, yet stil populate the combo box. Thanks
<%
set db=server.createobject("adodb.connection")
set orseof=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("skiRossy.mdb")
orseof.open "tblprivate",db
%>
<% Do While Not orseof.EOF ' define the ListBox OPTIONs %>
<OPTION VALUE="<%= orseof("skill") %>"> <%= orseof("skill") %>
<% orseof.MoveNext %>
<% Loop %>
<% orseof.Close %>
</SELECT>
Upvotes: 1
Views: 225
Reputation: 4638
What is tblprivate. If it is the name of a table then you need to replace it in that context with a SQL query, eg orseof.open "select skill from tblprivate",db
if skill is the only field you want to use in your select, (or "select * from tblprivate") if there are other fields you want to add.
You're using an ODBC connection string, which should work fine, but OLEDB strings are generally considered to be more robust eg
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.Mappath("skiRossy.mdb")
Upvotes: 1