devxlogo

Populating ListBox from Recordset Values

Populating ListBox from Recordset Values

Question:

I am trying to populate a drop-down listbox with the data from a table within my database and a blank line. The code I am using is as follows:

Fees Test<%'name the variablesDim dcGamelvlDim rsGamelvlDim OptionString'establish my connectionSet dcGamelvl = Server.CreateObject("ADODB.Connection")Set rsGamelvl = Server.CreateObject("ADODB.Recordset")dcGamelvl.Open "assignor"rsGamelvl.Open "SELECT * FROM gamelvl", dcGamelvl'fill my variables witht the table dataOptionString = ""Do Until rsGamelvl.EOF            OptionString = OptionString &_                       ""             rsGamelvl.MoveNextLoop'close my connectionrsGamelvl.ClosedcGamelvl.CloseSet rsGamelvl = NothingSet dcGamelvl = Nothing%>

Game Level

When I call up the ASP page, the page appears, but the dropdown box is empty. What am I doing wrong?

Answer:

Your drop-down box is empty because you did not place any values in it.

An HTML drop-down box (a