Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show records where field=YES

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
US
I am new to ASP & MDB files through ADO connections...and I need to write a query that only displays records with a certain field that equals "yes". Here is the general code I am using:

<%

Dim cnnSimple
Dim rstSimple
Dim strDBPath

strDBPath = Server.MapPath(&quot;database.mdb&quot;)

Set cnnSimple = Server.CreateObject(&quot;ADODB.Connection&quot;)

cnnSimple.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & strDBPath & &quot;;&quot;

Set rstSimple = cnnSimple.Execute(&quot;SELECT * FROM rent&quot;)

%>
 
This should work if the field is a text field

SELECT * FROM rent
where yourfield ='yes'

if the field is a boolean then try

SELECT * FROM rent
where yourfield = -1

Hope this helps

Andy
 
Thanks! now I just need to figure out where to place that in my code... (haha - laugh at me)
 
Here you go.

Code:
<%
Dim cnnSimple 
Dim rstSimple  
Dim strDBPath  
Dim strQuery

strDBPath = Server.MapPath(&quot;database.mdb&quot;)

Set cnnSimple = Server.CreateObject(&quot;ADODB.Connection&quot;)

cnnSimple.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & strDBPath & &quot;;&quot;

strQuery = &quot;SELECT * FROM rent WHERE
fieldname
Code:
 = 'yes'&quot;

Set rstSimple = cnnSimple.Execute(strQuery)

WHILE NOT rstSimple.EOF
  Response.Write rstSimple(&quot;
fieldname
Code:
&quot;) & &quot;<br>&quot;
  rstSimple.MoveNext
WEND
%>

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top