Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: not able to use wild card search


Message #1 by "Manish Agarwal" <mpc@c...> on Fri, 14 Dec 2001 20:32:36
I am using an access database but I am not able to use the wildcard search.

If I wanted to pull only F_NAME records that started with the letter a, 

HOW TO DO THAT



The script which i wrote is as follows---



<%@ LANGUAGE="VBSCRIPT" %>



<html>

<head>

<title>Client Search Results!</title>



</head>





<body>

<%

Dim SqlJunk

Dim n

n = Request.Form("dainbox")

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

dbGlobalWeb.Open("poddar")

sqlJunk = "SELECT * FROM PODDAR WHERE FNAME LIKE '"& n & "' "





Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")

rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3 

%>

<%

If rsGlobalWeb.BOF and rsGlobalWeb.EOF Then%>



<h2 align="center">We did not find a match!</h2>

<%Else%>





<%If Not rsGlobalWeb.BOF Then%>



<h2>Here are the results of your search:</h2>





<form action="DaEngine.asp" method="post" name="log">

<table border="0" cellpadding="1.5" cellspacing="3" align="center">

<tr bgcolor="#800000">

	

	<th><font color="white" face="Verdana, Arial" size=2>First 

Name:</font></th>

	<th><font color="white" face="Verdana, Arial" size=2>Last 

Name:</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>City:</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>State:</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>Country:</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>Zip:</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>HomeTown:</font></th>

	<th><font color="white" face="Verdana, Arial" size=2>Room 

No.</font></th>

	<th><font color="white" face="Verdana, Arial" 

size=2>View:</font></th>

</tr>



<%

	Do While Not rsGlobalWeb.EOF

	%>

<tr bgcolor="#DADADA">

    

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("FNAME")%>

</td>

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("LNAME")%>

</td>

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("CITY")%>

</td>

       <td><font face="Verdana, Arial" size=2 color="#000080"><%

=rsGlobalWeb("STATE")%>

</td>

       <td><font face="Verdana, Arial" size=2 color="#000080"><%

=rsGlobalWeb("COUNTRY")%>

</td>

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("PIN")%>

</td>

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("HOMETOWN")%>

</td>

      <td><font face="Verdana, Arial" size=2 color="#000080"><%=rsGlobalWeb

("ROOMNO")%>

</td>

      <td> <font face="Verdana, Arial" size=2 color="#000080"><A HREF 

=      "view.asp?NAME=<%=rsGlobalWeb("sno")%>">View</A>

</td>



      

</TR>

<% rsGlobalWeb.MoveNext

	Loop

	%>



<%End If%>

<%End If%>

<%

rsGlobalWeb.Close

dbGlobalWeb.Close

%>



</table>

</body>

</html>





Waiting for all your help

Manish

Message #2 by "Kim Iwan Hansen" <kimiwan@k...> on Fri, 14 Dec 2001 22:01:21 +0100
You have to use the wild card % to do that ;-)



SELECT f_name FROM table WHERE f_name LIKE 'a%';



-Kim







> -----Original Message-----

> From: Manish Agarwal [mailto:mpc@c...]

> Sent: 14. december 2001 20:33

> To: ASP Databases

> Subject: [asp_databases] not able to use wild card search

> 

> 

> I am using an access database but I am not able to use the 

> wildcard search.

> If I wanted to pull only F_NAME records that started with the letter a, 

> HOW TO DO THAT

> 

> The script which i wrote is as follows---

> 

> <%@ LANGUAGE="VBSCRIPT" %>

> 

> <html>

> <head>

> <title>Client Search Results!</title>

> 

> </head>

> 

> 

> <body>

> <%

> Dim SqlJunk

> Dim n

> n = Request.Form("dainbox")

> Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")

> dbGlobalWeb.Open("poddar")

> sqlJunk = "SELECT * FROM PODDAR WHERE FNAME LIKE '"& n & "' "

> 

> 

> Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")

> rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3 

> %>

> <%

> If rsGlobalWeb.BOF and rsGlobalWeb.EOF Then%>

> 

> <h2 align="center">We did not find a match!</h2>

> <%Else%>

> 

> 

> <%If Not rsGlobalWeb.BOF Then%>

> 

> <h2>Here are the results of your search:</h2>

> 

> 

> <form action="DaEngine.asp" method="post" name="log">

> <table border="0" cellpadding="1.5" cellspacing="3" align="center">

> <tr bgcolor="#800000">

> 	

> 	<th><font color="white" face="Verdana, Arial" size=2>First 

> Name:</font></th>

> 	<th><font color="white" face="Verdana, Arial" size=2>Last 

> Name:</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>City:</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>State:</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>Country:</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>Zip:</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>HomeTown:</font></th>

> 	<th><font color="white" face="Verdana, Arial" size=2>Room 

> No.</font></th>

> 	<th><font color="white" face="Verdana, Arial" 

> size=2>View:</font></th>

> </tr>

> 

> <%

> 	Do While Not rsGlobalWeb.EOF

> 	%>

> <tr bgcolor="#DADADA">

>     

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("FNAME")%>

> </td>

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("LNAME")%>

> </td>

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("CITY")%>

> </td>

>        <td><font face="Verdana, Arial" size=2 color="#000080"><%

> =rsGlobalWeb("STATE")%>

> </td>

>        <td><font face="Verdana, Arial" size=2 color="#000080"><%

> =rsGlobalWeb("COUNTRY")%>

> </td>

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("PIN")%>

> </td>

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("HOMETOWN")%>

> </td>

>       <td><font face="Verdana, Arial" size=2 

> color="#000080"><%=rsGlobalWeb

> ("ROOMNO")%>

> </td>

>       <td> <font face="Verdana, Arial" size=2 color="#000080"><A HREF 

> =      "view.asp?NAME=<%=rsGlobalWeb("sno")%>">View</A>

> </td>

> 

>       

> </TR>

> <% rsGlobalWeb.MoveNext

> 	Loop

> 	%>

> 

> <%End If%>

> <%End If%>

> <%

> rsGlobalWeb.Close

> dbGlobalWeb.Close

> %>

> 

> </table>

> </body>

> </html>

> 

> 

> Waiting for all your help

> Manish

> 




> $subst('Email.Unsub').

> 


  Return to Index