|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL Results to be used in an html list
Hi,
Does anyone know how to put the results of a SQL query into an HTML drop list. For example, if I were to get a table of names I would want them in a list that would allow me to choose one. Thanks, Cam |
|
#2
|
||||
|
||||
|
Code:
Create your connection and recordset objects
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Open your connectionstring
Conn.Open("Your ConnectionString")
For information on Connectionstrings Click Here
set recordset object to sql statement
rs = Conn.Execute("SELECT * FROM <tableName>")
If there are no records, then display the message
If(rs.eof) Then
Response.write("No records returned")
End If
Else display the returned records in a dropdown list
Response.write("<select name='test'>")
do until rs.eof
Response.write("<option>" & rs("field1") & "</option>")
rs.movenext
loop
Response.write("</select>")
Close the connection
Conn.close
Set your objects to nothing
Set rs = nothing
Set Conn = nothing
|
|
#3
|
|||
|
|||
|
Thanks Memnoch
![]() |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL Results to be used in an html list |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|