dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Search for anything?

  1. #1
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    202

    Search for anything?

    I would like to create a search function where people can type anything into the search field and it will bring up data that matches the search parameter.

    So far I'm only able to have them search for parameters in a specific column with this code (created by Dreamweaver):

    <%
    Dim Recordset1
    Dim Recordset1_numRows

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_EventsDB_STRING
    Recordset1.Source = "SELECT IdMeeting, Date_S, EventName, Location, ProjectLead, Status, TypeOfMeeting, MarketingLead, Industry FROM Meeting WHERE Industry LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' ORDER BY Date_S ASC"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()

    Recordset1_numRows = 0
    %>

    I don't see an option to have the search look through all columns instead of just one particular (bolded), something like this:

    Recordset1.Source = "SELECT IdMeeting, Date_S, EventName, Location, ProjectLead, Status, TypeOfMeeting, MarketingLead, Industry FROM Meeting WHERE IdMeeting, Date_S, EventName, Location, ProjectLead, Status, TypeOfMeeting, MarketingLead, Industry LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' ORDER BY Date_S ASC"

    But this doesn't work. Maybe I should use brackets?
    Last edited by Illufox; 03-18-2005 at 01:56 PM.

  2. #2
    Join Date
    Sep 2003
    Location
    Utah
    Posts
    396
    You have the right idea. More like this:

    Recordset1.Source = "SELECT IdMeeting, Date_S, EventName, Location, ProjectLead, Status, TypeOfMeeting, MarketingLead, Industry FROM Meeting WHERE IdMeeting LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR Date_S LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR EventName LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR Location LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR ProjectLead LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR Status LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR TypeOfMeeting LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR MarketingLead LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' OR Industry LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' ORDER BY Date_S ASC"

    However, you should know that the LIKE comparison only works on text fields. So, if Date_S is a date field then you would want to change:

    Date_S LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'

    to

    Date_S = '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'

    Give that a go and see if it gets you closer.

  3. #3
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    202
    That works! Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles