Search for any column?

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Search for any column?

    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 the code below. I don't see an option to have the search look through all
    columns instead of just one particular. I've tried to add all columns to the
    WHERE statement but that caused an error.

    <%
    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
    %>

    illufox Guest

  2. Similar Questions and Discussions

    1. Move bound column to right of dynamic column in datagrid?
      I have a datatable that I am binding to a C# ASP.NET 1.1 web page. I also want to put an "Edit" column on the datagrid. However, whenever I use...
    2. ANN: InterAKT Site Search - search in multiple tables
      Hello, We have just released a new product, MX Site Search, meant to help web developers and designers create a search form in their dynamic...
    3. Bound Column or Template Column (w dAdapater?) in DataGrid
      I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL...
    4. #25786 [NEW]: PHP website uses cookies to remember last search phrase in search box
      From: tipsen at imada dot sdu dot dk Operating system: - PHP version: Irrelevant PHP Bug Type: Unknown/Other Function Bug...
    5. how to Add different controls(textBox,DropDownList or some ) in the same column,based upon the value in the previous column (Say second Colum which contain dropdown with some values) ?
      I am new to ASP.NET. I am facing problem with datagrid. I will explain prob now. In the datagrid the first column is name in the second...
  3. #2

    Default Re: Search for any column?


    "illufox" <webforumsuser@macromedia.com> wrote in message
    news:d1fbf4$n6e$1@forums.macromedia.com...
    > 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 the code below. I don't see an option to have the search look
    through all
    > columns instead of just one particular. I've tried to add all columns to
    the
    > WHERE statement but that caused an error.
    You have to specify each column you want to search (in pseudo-sql):

    SELECT * FROM mytable
    WHERE field1 like '%search%'
    AND field2 LIKE '%search%'
    AND field3 LIKE '%search%' etc

    So basically you would write the SQL exactly as you have done, but include a
    filter for each field that you want to search.

    If you have my book Dreamweaver MX 2004: The Complete Reference, there is
    code that shows how to do it automatically in every server language. I also
    have an extension that expands on this code available for a small fee from
    [url]http://www.tom-muck.com/extensions/help/DynamicSearchPHP/[/url]


    --
    -------------------------------------------
    Tom Muck
    co-author Dreamweaver MX 2004: The Complete Reference
    [url]http://www.tom-muck.com/[/url]

    Extending Knowledge, Daily
    [url]http://www.CommunityMX.com/[/url]


    Tom Muck Guest

  4. #3

    Default Re: Search for any column?

    Ok, I've done that but now I get no results at all. Shouldn't it be 'OR' insted
    of 'AND'? Here is the updated code:

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

    illufox Guest

  5. #4

    Default Re: Search for any column?

    Another method might be to concatenate the fields to search. eg

    select * from t where f1 & f2 & f3 like '%myParam%'

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004



    Julian Roberts Guest

  6. #5

    Default Re: Search for any column?

    Yes of course it should be OR and not AND !

    But Julian's answer is the brilliant one ! Had no idea one could
    concatenate fields !

    Bernard

    illufox wrote:
    > Ok, I've done that but now I get no results at all. Shouldn't it be 'OR' insted
    > of 'AND'? Here is the updated code:
    >
    > Recordset1.Source = "SELECT IdMeeting, Date_S, EventName, Location,
    > ProjectLead, Status, TypeOfMeeting, MarketingLead, Industry FROM Meeting WHERE
    > Industry LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' AND
    > EventName LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' AND
    > Location LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' AND
    > ProjectLead LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' AND
    > Status LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%' AND
    > TypeOfMeeting LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'ORDER
    > BY Date_S ASC"
    >
    bthouin Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139