logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > ASP
Register FAQ Members List Search Today's Posts Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 02-02-2011, 05:55 PM   #1
Ciombe
 
Join Date: Feb 2011
Posts: 4
Default SQL Query using LIKE

Hi,
id' like to create a little search engine on my site and i have using this code for the DB connection in my result page called results.asp.

I get the values by a search page which have field called "campotesto1" anche select field called "select1"

HTML Code:
<%
Dim rsRicerca__MMColParam
rsRicerca__MMColParam = "-1"
If (Request.Form("campotesto1") <> "") Then 
  rsRicerca__MMColParam = Request.Form("campotesto1")
End If
%>
<%
Dim rsRicerca__MMColParam1
rsRicerca__MMColParam1 = "1"
If (Request.Form("select1") <> "") Then 
  rsRicerca__MMColParam1 = Request.Form("select1")
End If
%>
<%
Dim rsRicerca
Dim rsRicerca_cmd
Dim rsRicerca_numRows

Set rsRicerca_cmd = Server.CreateObject ("ADODB.Command")
rsRicerca_cmd.ActiveConnection = MM_dbShoemakers_STRING
rsRicerca_cmd.CommandText = "SELECT * FROM table WHERE field LIKE '%" + Replace(?, "'", "''") + "%' AND select_field = ? ORDER BY name DESC" 
rsRicerca_cmd.Prepared = true
rsRicerca_cmd.Parameters.Append rsRicerca_cmd.CreateParameter("param1", 200, 1, 255, rsRicerca__MMColParam) ' adVarChar
rsRicerca_cmd.Parameters.Append rsRicerca_cmd.CreateParameter("param2", 5, 1, -1, rsRicerca__MMColParam1) ' adDouble

Set rsRicerca = rsRicerca_cmd.Execute
rsRicerca_numRows = 0
%>
i use DW CS5 and ASP.

This query doesn't work cause a obtain and error:

"syntax error (missed operator), in query expression 'ield LIKE '%" + Replace(-1, "'", "''") + "%' AND select_field = 1 ORDER BY name DESC"


Where i'm in wrong?
Ciombe is offline   Reply With Quote
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com