Results 1 to 3 of 3

Thread: sql help

  1. #1
    Join Date
    May 2006
    Posts
    3

    Red face Unanswered: sql help

    I have got this code below. plesae can you help me

    <%

    Dim strURL
    dim con, Rs, Connstring

    Dim cnnSearch ' ADO connection
    Dim rstSearch ' ADO recordset
    'Dim strDBPath ' path to our Access database (*.mdb) file

    Dim strSQL ' The SQL Query we build on the fly
    Dim strSearch ' The text being looked for

    strURL = Request.ServerVariables("URL")

    strSearch = Request.QueryString("search")

    %>
    <form action="<%= strURL %>" method="get">
    <input name="search" value="<%= strSearch %>" />
    <input type="submit" />
    </form>

    <%
    If strSearch <> "" Then

    ' strDBPath = Server.MapPath("database.mdb")
    Set cnnSearch = Server.CreateObject("ADODB.Connection")
    Set cnnSearch="dsn=test;uid=test;pwd=test;"

    ' Build our query based on the input.
    strSQL = "SELECT PROPERTY_KEY, ADDRESS1, COST_CENTRE " _
    & "FROM [PROPERTIES] " _
    & "WHERE PROPERTY_KEY LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
    & "OR ADDRESS1 LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
    & "ORDER BY PROPERTY_KEY;"


    Set rstSearch = cnnSearch.Execute(strSQL)
    %>
    <table border="1">
    <tr>
    <th>Name</th>
    <th>Sales</th>
    </tr>
    <%
    Do While Not rstSearch.EOF
    %>
    <tr>
    <td><%= rstSearch.Fields("PROPERTY_KEY").Value %></td>
    <td><%= rstSearch.Fields("ADDRESS1").Value %></td>
    <td><%= rstSearch.Fields("COST_CENTRE").Value %></td>
    </tr>
    <%

    rstSearch.MoveNext
    Loop
    %>
    </table>
    <%

    rstSearch.Close
    Set rstSearch = Nothing
    cnnSearch.Close
    Set cnnSearch = Nothing
    End If

    %>

  2. #2
    Join Date
    Feb 2004
    Posts
    86
    So what's your question?

  3. #3
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    Also looks like Access to me.

Posting Permissions

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