Skip to main content
Participating Frequently
March 15, 2011
Question

Advanced filter recordset asp

  • March 15, 2011
  • 1 reply
  • 2824 views

Hi,

I m trying to filter an asp recordset with % wildcart but impossible to do it.

..!!

Have got a asp form with a dropdown list based on a recordset that stores value (numeric) in a variable (id).


So this variable is used on my result asp page to filter a new recordset by this numeric value.


Im using wild card in order to display all records like this SQL query:

SELECT *
FROM proprietes
WHERE ville LIKE %MMColParam%           

MMColParam defined like this :
Numeric
Request.Form("ville")

default value %

So when it generates sql query, it gives SELECT *FROM proprietes WHERE ville LIKE '%MMColParam%' and testing it, it works (testing recordset in dream) but saving it and reopens recordset the query becomes :   SELECT *FROM proprietes WHERE ville LIKE %MMColParam%   and testing recordset gives error !!

Someone can help me?

Thanks a lot.

This topic has been closed for replies.

1 reply

X-Slider
Known Participant
March 15, 2011

try this

"Select * From proprietes
WHERE ville LIKE %" + MMColParam + "%"

LSTEPHANAuthor
Participating Frequently
March 15, 2011

I become crazy it doesn't work and i don't understand !

Thanks

LSTEPHANAuthor
Participating Frequently
March 16, 2011

>I m just trying to search for a specific numeric

>value or display all values for a % default value.

I assume it is working fine if searching for a specific value correct?

To return all values, you will need to add code that evaluates the value passed from the form. If it is the wildcard character (or whatever you define), then don't include a where clause in your SQL. I don't think there's a way to do this in the server behavior but I could be wrong. I dont typically use server behaviors for recordsets. Look for something in there like 'optional parameter'. Otherwise, you'll need to code this by hand:

If (Request.Form("ville") <> "%") Then
  Recordset1_cmd.CommandText = "SELECT * FROM proprietes WHERE ville Like ?"

Else

  Recordset1_cmd.CommandText = "SELECT * FROM proprietes"
End If


Hi

Thanks for your response.

I will do it like you wrote

This was possible with Ultradev (macromedia) i ve done it with server behavior but it appears that with dremweaver it's impossible.

Have a nice day.