asp results page

S

Stu

I'm using this code to display results from a database:

<%
companyname = Request.QueryString( "companyname")





Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=C:mypath\mydatabase.mdb"

quote = "SELECT * FROM Results WHERE company LIKE '%"&
companyname &"%'"

Set quote = Conn.Execute( quote)

if quote.eof then
Response.write("No records found.")
Response.End
end if


%>

The problem I'm having is I'm searching for a company name
and there are more than one record with the same company
name but my results page will only display one record.
Also I'm displaying more fields than just the company
name, but company name is what field is used in the
query. All the fields together are formatted to make up a
quote form. I need this code to display all the records
not just the first one it comes to...and all the other
fields with it. The frontpage database results wizard
does this when you select how many records you want
displayed at one time. If you select 1 then a nav bar is
created at the bottom of the results page to take you to
the next record...this is what I'm trying to
accomplish...but without using the wizard...please help
 
J

Jon Spivey

Hi Stu,

You need to loop through the results, eg

<%
sql="select * from table where company like '%" & companyname & "%'"
set quote = conn.execute(sql)
if not quote.eof then
do until quote.eof
response.write quote(0) & "<BR>"
quote.movenext
loop
else
response.write "no results"
end if
%>

Hopefully that will get you started
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top