Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: SQL script to return all records


Message #1 by Joseph Coppola <joco@e...> on Thu, 25 Apr 2002 23:06:02 -0400
Help!  I am using a form to perform a db search, but I want to return
all records, so I am using a LIKE statement.  Well the query runs
correctly in Access but doesn't from an ASP page (no records are
returned)... SO whats the problem with my statement?

TIA,
Joe



<%
Dim ConnSafariDB 
Dim strSQL
Dim rstSearch
Dim SafariType, name, date, price


SafariType=Request("cmbType")

If SafariType="All" then SafariType="*"

Set connSafariDB = Server.CreateObject("ADODB.Connection")

strDBPath = Server.MapPath("safari.mdb")
connSafariDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strDBPath & ";"

//**********************************************************************
*********
//THIS SECTION OF THE SQL QUERY
strSQL = "SELECT tblSafari.*, tblSafari.Type " & _
		"FROM tblSafari " & _
		"WHERE (((tblSafari.Type) LIKE '*'));" // '" &
SafariType & "'));"
//**********************************************************************
********

Set rstSearch = connSafariDB.Execute(strSQL)		
%>
<% response.write(strSQL) %>
	<table border="1">
	<tr>
	<th>Trip Name</th>
	<th>StartDate</th>
	<th>EndDate</th>
	<th>Price</th>
	</tr>
	<%
	Do While Not rstSearch.EOF
		%>
		<tr>
		<td><%=rstSearch.Fields("Trip Name").Value %> </td>
		<td><%=rstSearch.Fields("Depart US").Value %> </td>
		<td><%=rstSearch.Fields("Arrive US").Value %> </td>
		<td><%=rstSearch.Fields("Adult Package Price").Value %>
</td>	
		
    <td><a href="http://www.firstxpressions.com"
target="main">test</a></td>	
		</tr>
		<%

		rstSearch.MoveNext
	Loop	
	%>
	</table>

Message #2 by "Ken Schaefer" <ken@a...> on Fri, 26 Apr 2002 14:10:02 +1000
www.adopenstatic.com/faq/likequeries.asp

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Joseph Coppola" <joco@e...>
Subject: [asp_web_howto] SQL script to return all records


: Help!  I am using a form to perform a db search, but I want to return
: all records, so I am using a LIKE statement.  Well the query runs
: correctly in Access but doesn't from an ASP page (no records are
: returned)... SO whats the problem with my statement?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index