Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How could i Fill a Combo with data from a database in ASP


Message #1 by "michell varela fuentes" <miguecorr@h...> on Thu, 19 Sep 2002 23:31:27
OK thats my cuestion:How could i fill a Combo with the result of a 
Database query in Asp, please if someone have idea please help me!!
Message #2 by "Paulo Fernandes" <paulofernandes@c...> on Fri, 20 Sep 2002 09:05:44 +0100
Hi,

You can try the following:

Open up the database
====================

<!-- #include file="includes\adovbs.inc" -->
<%
	Dim objConn, StrSQL, rsTest
	Set objConn = Server.CreateObject("ADODB.Connection")

	objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
				 "Data Source=" &
server.mappath("fpdb/products.mdb")

	Set rsTest = Server.CreateObject("ADODB.Recordset")
	strSQL = "SELECT * FROM tbl_test ORDER BY fieldtoshow ASC;"
	rsTest.Open strSQL, objConn, adOpenKeyset, adLockPessimistic,
adCmdText

%>

Then, when you want your select box to be displayed, type:
==========================================================

<select size="1" name="example">
<%
with rsTest
	if not .bof then .movefirst
	do while not .eof
%>
    <option value="<%= .fields("fieldtoshow")%>"><%
.fields("fieldtoshow ")%></option>
<%
	.movenext
	loop
end with
%>
</select>

Cheers

PauloF




-----Original Message-----
From: michell varela fuentes [mailto:miguecorr@h...] 
Sent: quinta-feira, 19 de Setembro de 2002 23:31
To: ASP Databases
Subject: [asp_databases] How could i Fill a Combo with data from a
database in ASP

OK thats my cuestion:How could i fill a Combo with the result of a 
Database query in Asp, please if someone have idea please help me!!


  Return to Index