ASP search quey

Discussion in 'C#' started by dm123, Jul 25, 2009.

  1. #1
    Hi,

    I am new to asp and have been working from a book call ASP Made Simple. I have been trying out a few examples from the book and the code below doesn't seem to work.

    Please could you help me and let me know how to get it to work?

    Thank you.

    <html>
    <body>
    <%
    if session("yes")=1 then
    session("x")=request ("keyword")
    session("y")=request("cont")
    session("yes")=2
    end if
    x=session("x")
    y=session("y")
    query="select id, type,location,brief,verbose,email,wages from employ where (cont="& y &") and (type like '%"& x &"%' or location like '%"& x &"%' or brief like '%"& x &"%' or verbose like '%"& x & "%' or email like '%"& x & "%' or wages like '%"& x & "%' )"
    set database=server.createOject("ADODB.connection")
    database.open ("jobs")
    Set RSList=server.createObject("ADODB.recordset")
    RSList.open query,database,3
    dim numpages
    dim currentpage
    RSlist.pagesize=10
    if request.querystring("page")="" then
    currentpage=1
    else
    currentpage=Clnt (request.querystring("page"))
    end if
    numpages = rslist.PageCount

    if currentpage > numpages Then currentpage = numpages
    if currentpage < 1 Then numpages =1
    if numpages=0 then
    %><center><b><%
    response.write "No jobs match your search criteria. Please try again."
    %> </b><br><br><a href="title.asp">Back to Search</a></center><%

    response.end
    end if

    s="The search criteria you entered returned"

    if y="yes" then
    n="contract"
    else n="permanent"
    end if

    c=rslist.recordcount
    s=s+" "+cstr(c)+ " " +n+" "

    if C<> 1 then
    s=s+"jobs"
    elseif c=1 then
    s=s+"job"

    end if%><font color="blue"<%
    response.write("<center>"+s)
    RSlist.AbsolutePage=currentpage
    %>

    <br><<hr>
    <font size="7" color="blue"><b>
    <table border=0 width=98% cellspacing=1>
    <tr>
    <th>Type</th>
    <th>Location</th>
    <th>Description</th>
    <th>Wages</th>
    </b>
    </tr>
    </font>

    <%
    dim numrows
    numrows=0
    do until rslist.eof or numrows>=RSlist.PageSize

    aa=RSlist("type")
    ab=RSlist("location")
    ac=RSlist("brief")
    ad=RSlist("wages")
    %>

    <tr>
    <td><%=aa%></td>
    <td><%=ab%></td>
    <td><a href="jobdetails.asp?ID=<%=rslist("ID")%>"><%=ac%></a>
    </td>
    <td><%=ad%></td>
    </tr>

    <%
    rslist.movenext
    numrows=numrows+1
    loop
    %>

    </table>
    <hr><br><center>
    <% if currentPage>1 then
    %>
    <a href="process.asp?page=<%=currentpage-1%>"> &nbspPrevious Jobs
    </a>&nbsp
    <%
    end if %>

    <% if currentPage<rslist.pagecount then
    %>

    <a href="process.asp?page=<%=currentpage+1%>"> &nbspNext Jobs
    </a>&nbsp
    <%
    end if %>

    <br><br>
    <a href="title.asp">Back to Search </a>

    <%
    rslist.close
    set rslist = nothing
    database.close
    set database = nothing
    %>

    </center>
    </body>
    </html>
     
    dm123, Jul 25, 2009 IP
  2. EmeraldOne

    EmeraldOne Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hey,
    You have error on that line.
    set database=server.createOject("ADODB.connection")
    Change to:
    set database=server.CreateObject("ADODB.connection")

    Add "b" of the oBject for now..

    The next line you have ("Jobs")...
    What is that mean???
    You need to have the connection string, and there is no access to ("Jobs") to be valid...
    It should be a string that will compose your server, database, maybe user name and password..

    let me know..

    Isaac,
    http://www.7Live7.com
     
    EmeraldOne, Jul 25, 2009 IP
  3. dm123

    dm123 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    Than you for your help,

    I tried to changed the
    set database=server.createOject("ADODB.connection")
    Change to:
    set database=server.CreateObject("ADODB.connection")

    and tried

    Add "b" of the oBject for now..

    but had the following error message:

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    /Myweb/test/Process.asp, line 13


    is there any other suggestions you may have please.

    Thank you
     
    dm123, Jul 26, 2009 IP