searching a mysql query with a form (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


crosscreek -> searching a mysql query with a form (3/2/2008 1:36:10)

I am trying to create a page where someone can search the database for similar name matches.

For instance if you type in cross in the search form it will bring up

Cross Creek
Cross Creek's gal
and so on.

But if there's not matches then it would bring up no records.

I have the connection to the database, I just can't get it to pull the information. I know the query is correct, because I tested it.

Search form page

<form method=POST action="check.asp">
Search <input type=text name="doggy" size="33">
<p> <br>
<input type=submit value="Search">
</p>
</form>

check.asp page

<%@ Language=VBScript %>

<!-- #include virtual="/adovbs.inc" -->
<!-- #include file="openconn.inc" -->

<%

'read in the characters the user entered
Dim strDoggy
strDoggy = Trim(Request("doggy"))

Dim strSQL
strSQL = "SELECT Name FROM tblDog WHERE Name LIKE '%strDoggy%'"

Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, myConn

If objRS.EOF then
Response.Write "no records"

Else
Response.Write "THERE'S A MATCH"
Do While Not objRS.EOF
objRS.MoveNext
Loop
End if

objRS.Close
Set objRS = Nothing

myConn.close
Set myConn = nothing
%>


Now I can get it to show NO Records, but not the dog Or in this case There's a match...I'll custom the page later.
I'm stumped. [sm=BangHead.gif]






crosscreek -> RE: searching a mysql query with a form (3/2/2008 11:52:25)

figured it out[:D]

Dim strDoggy
strDoggy = Trim(Request("doggy"))

Dim strSQL
strSQL = "SELECT name FROM tbldog WHERE name LIKE '%" & _
strDoggy & "%'"

CODE IS PICKY!!!

It does feel pretty go to figure it out....





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875