Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

A little help with ASP?

  • 31-03-2004 12:33pm
    #1
    Registered Users, Registered Users 2 Posts: 202 ✭✭


    hey all, does any know where i can get a 'simple' asp shopping cart to integrate with my website?

    any help greatly appreciated
    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    a little googl'ing goes a long way:
    http://www.aspin.com/home/webapps/shopping/carts for example..


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    thanks karoma for that,
    by the way does any one know an sql statement to
    bring up specific records from a database based on what a user enters in to the search field.
    thanks for any help


  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    you're gonna have to be a little more specific :)

    generally:

    html page: form/textfield
    POST/GET to nextpage.asp
    nextpage.asp -> get the input , put in variable...

    then SELECT * FROM tablename WHERE condition='variable'


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    thanks,
    i have a database with a list of games and there details - i want to allow customers to enter searches in a textfield(mini search engine)

    I need the sql statement that will check the database to see if their criteria exists eg i enter fifa2004 and i want it to bring all the details up on it such as price,platfrom etc
    and if its not there i will print on the screen not available

    basically i enter any game in the textfield and it show me details if it exists and shows me nothing if it doesnt exist


  • Registered Users, Registered Users 2 Posts: 4,780 ✭✭✭JohnK


    You could try:

    SELECT * FROM WHERE ([field] LIKE '%[UserInput]%')
    where:
    = the table you are searching
    [field] = the field you want to check
    [UserInput] = what the user is searching for
    EG: SELECT * FROM games WHERE (title LIKE '%fifa%')

    You can customise it some by removing the first or last '%'. The '%' is a wild card.
    EG: %fifa = starts with anything and ends with fifa
    fifa% = starts with fifa and ends with anything
    %fifa% = starts with anything has fifa somewhere in it and ends with anything.

    This should work with SQL Server but some different servers might need a slightly different syntax.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    thanks john k for that- server is down at d moment but will let you know how i get on!


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Have a look at this - Eire-Shop

    also there is a little code for the search page. might help.

    <%
    Dim SearchParam
    SearchParam = Trim(Request("SearchParam"))

    Dim CompType, t3_advSearch_String
    'Store type of query in CompType ie All Words/OR, Any Word/AND or Exact Phrase/EXACT
    CompType = Request("CompType")
    SearchColumn = "Table_Field + Table_Field"

    SearchField = "zzz"
    if(Request("SearchParam") <> "") then SearchField = Request("SearchParam")
    'Remove any single quotes from search field to eliminate potential errors.
    SearchField = Replace(SearchField, "'", "")
    SearchField = Replace(SearchField, " ", " ")

    'Checks the CompType, Executes this code if the option All words or Any Word is chosen
    if(CompType <> "EXACT") then
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%"
    'Splits the search criteria into seperate words and stores them in an Array
    SearchArray=Split(SearchField," ")
    for i = 0 to Ubound(SearchArray)
    if i > 0 then
    'Builds the sql statement using the CompType to substitute AND/OR
    t3_advSearch_String = t3_advSearch_String & " " & CompType & " " & SearchColumn & " LIKE '%"& SearchArray(i) & "%'"
    else
    'Ends the sql statement if there is only one word
    t3_advSearch_String = t3_advSearch_String & SearchArray(i) & "%' "
    end if
    next

    else
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%" & SearchField & "%' "
    end if

    Dim rsSearch__t3_String
    'rsSearch__t3_String = "WHERE ID=1"
    if (t3_advSearch_String <> "") then rsSearch__t3_String = t3_advSearch_String

    set rsSearch = Server.CreateObject("ADODB.Recordset")
    rsSearch.ActiveConnection = MM_conn_STRING
    rsSearch.Source = "SELECT * FROM Table_Name " + Replace(rsSearch__t3_String, "'", "'") + "AND P_Discontinued = 0 ORDER BY P_Price"
    rsSearch.CursorType = 0
    rsSearch.CursorLocation = 2
    rsSearch.LockType = 1
    rsSearch.Open()
    rsSearch_numRows = 0
    %>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    thanks a lot for that louie,will let you know how i get on


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    het johnk that works fine but it will just take something specific from the database i.e. what i have entered in the code eg
    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%fifa%')"
    this will display details on fifa

    i just want it to display results based on what a user enters in the search field?

    any ideas
    thanks!


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    searchfield = Trim(Request.Form("searchfield")


    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%searchfield%')"


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    tanx louie for the reply-still cant get it to work though,
    if you get a minute would you mind glancing over this as you would probably spot an error quicker than me- tanxs


    <%
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\Game Emporium.mdb"))

    search = Trim(Request.Form("search")
    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%search%')"
    set oRS = oConn.Execute(sSQL)

    Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-family:arial; font-size:8pt;'>")
    Response.Write("<tr bgcolor=black style='color:white;'>")
    Response.Write("<td>Game_id</td>")
    Response.Write("<td>Game_platform</td>")
    Response.Write("<td>Game_title</td>")
    Response.Write("<td>Game_price</td>")
    Response.Write("<td>Game_Qty</td>")

    Do While NOT oRS.EOF
    Response.Write("<tr><td>" & oRS("Game_id") & "</td></tr>")
    Response.Write("<td>" & oRS("Game_platform") & "</td>")
    Response.Write("<td>" & oRS("Game_title") & "</td>")
    Response.Write("<td>" & oRS("Game_price") & "</td>")
    Response.Write("<td>" & oRS("Game_Qty") & "</td>")
    oRS.MoveNext
    Loop
    Response.Write("</table><br><br>")

    oConn.Close
    Set oRS = Nothing
    Set oConn = Nothing
    %>


  • Registered Users, Registered Users 2 Posts: 18 Buttercup


    Hi All
    I am having some bother with a calendar I am working on . It has a database connected to it . What i am trying to do is once a date has past the record is deleted. So when the page is loaded it will check the database search for any record with a date older then the present and delete it. I am using ASP.NET with webmatrix in vb.net. Any help would be greatly appreciated and I'm sure i will have more questions to follow so if anyone can reccomend any sites with database calendars let me know
    Cheers


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    'You are missing the form.

    <form action="YourPageName" method="post" name="search" id="search">
    <br>
    <input name="search" type="text" id="search">
    <input name="Submit" type="submit" value="Search" title="Search For Products">
    </form>


    'Then your code will follow:

    <%
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\Game Emporium.mdb"))

    search = Trim(Request.Form("search")
    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%search%')"
    set oRS = oConn.Execute(sSQL)

    Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-family:arial; font-size:8pt;'>")
    Response.Write("<tr bgcolor=black style='color:white;'>")
    Response.Write("<td>Game_id</td>")
    Response.Write("<td>Game_platform</td>")
    Response.Write("<td>Game_title</td>")
    Response.Write("<td>Game_price</td>")
    Response.Write("<td>Game_Qty</td>")

    Do While NOT oRS.EOF
    Response.Write("<tr><td>" & oRS("Game_id") & "</td></tr>")
    Response.Write("<td>" & oRS("Game_platform") & "</td>")
    Response.Write("<td>" & oRS("Game_title") & "</td>")
    Response.Write("<td>" & oRS("Game_price") & "</td>")
    Response.Write("<td>" & oRS("Game_Qty") & "</td>")
    oRS.MoveNext
    Loop
    Response.Write("</table><br><br>")

    oConn.Close
    Set oRS = Nothing
    Set oConn = Nothing
    %>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    the way i have it is that my form is on one page called ss.html
    and my asp is on another page called search.asp

    within ss.html there is a link to search.asp

    should the form be on the same page as the asp?

    thanks


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Paste this code into the ss.html page


    <form action="search.asp" method="post" name="search" id="search">
    <br>
    <input name="search" type="text" id="search">
    <input name="Submit" type="submit" value="Search" title="Search For Products">
    </form>


    If you are getting an error let me know what it says.


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    it coming up: the page cannot be displayed!

    and after our url it says: search.asp?search=fifa&Submit=Search


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    I see everyones' college projects are due this month then... :rolleyes:


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Are those two pages in the same directory.

    try replacing the search.asp in the form action="search.asp"

    with a Relative to Site Link as http://www.yoursite.com/search.asp


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    ye the two are in the same directory ,replaced form action with what you said and it came up :
    Information Alert

    Status : 502 Bad Gateway

    Description : The origin web server encountered an unexpected condition which prevented it from fulfilling the request. Please try your request again.



    i changed my select statement to bring up everything in the database and it worked so it wasnt the server crashing or anything.

    could it be something with the select line??
    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%search%')"

    cheers


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    change this search = Trim(Request.Form("search")

    to this

    search = Trim(Request.Form("search"))

    you are missing a closing bracket - sorry


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    hey louie, i mad that change and what happens now is that you enter your search and it brings up the table but with no details in it.

    thanks for your time louie


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Show us the full page code.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    create a new page called search1.asp
    and copy the bellow code into it see what's happening:

    <%@LANGUAGE=&quot;VBSCRIPT" CODEPAGE="1252"%>
    <%response.buffer = true%>
    <%
    Dim SearchParam
    SearchParam = Trim(Request("SearchParam"))

    Dim CompType, t3_advSearch_String
    'Store type of query in CompType ie All Words/OR, Any Word/AND or Exact Phrase/EXACT
    CompType = Request("CompType")
    SearchColumn = "Game_title"

    SearchField = "zzz"
    if(Request("SearchParam") <> "") then SearchField = Request("SearchParam")
    'Remove any single quotes from search field to eliminate potential errors.
    SearchField = Replace(SearchField, "'", "")
    SearchField = Replace(SearchField, " ", " ")

    'Checks the CompType, Executes this code if the option All words or Any Word is chosen
    if(CompType <> "EXACT") then
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%"
    'Splits the search criteria into seperate words and stores them in an Array
    SearchArray=Split(SearchField," ")
    for i = 0 to Ubound(SearchArray)
    if i > 0 then
    'Builds the sql statement using the CompType to substitute AND/OR
    t3_advSearch_String = t3_advSearch_String & " " & CompType & " " & SearchColumn & " LIKE '%"& SearchArray(i) & "%'"
    else
    'Ends the sql statement if there is only one word
    t3_advSearch_String = t3_advSearch_String & SearchArray(i) & "%' "
    end if
    next

    else
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%" & SearchField & "%' "
    end if

    Dim rsSearch__t3_String
    'rsSearch__t3_String = "WHERE ID=1"
    if (t3_advSearch_String <> "") then rsSearch__t3_String = t3_advSearch_String

    set rsSearch = Server.CreateObject("ADODB.Recordset")
    rsSearch.ActiveConnection =("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\Game Emporium.mdb") & ";Persist Security Info=False")
    rsSearch.Source = "SELECT * FROM Game " + Replace(rsSearch__t3_String, "'", "'")
    rsSearch.CursorType = 0
    rsSearch.CursorLocation = 2
    rsSearch.LockType = 1
    rsSearch.Open()
    rsSearch_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <form name="search" id="search" method="get" action="search1.asp">
    <br />
    <br />
    <input name="SearchParam" type="text" class="btn" id="SearchParam" value="<%=UCase(Trim(Request("SearchParam")))%>" size="45" />
    <select name="CompType" class="TEXTAREA" id="CompType">
    <option value="<%=Request("CompType")%>" selected="selected"><%=Request("CompType")%></option>
    <option value="OR">All Words</option>
    <option value="AND">Any Word</option>
    <option value="EXACT">Exact Phrase</option>
    </select>
    <input name="Search" type="submit" class="btn" id="Search" value="Search" />
    </form>
    <li><%=(rsSearch.Fields.Item("P_Name").Value)%></li>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    My Form page: (ss.html)

    <html>
    <body>
    <BR>
    <form action="search.asp" method="post" name="search" id="search">
    <br>
    <input name="search" type="text" id="search">
    <input name="Submit" type="submit" value="Search" title="Search For Products">
    </form>


    </body>
    </html>



    My ASP Page(search.asp)

    <html>
    <head>
    <title>Weather Database</title>
    </head>
    <body>
    <p><font face="Arial" size="4" color="#000080">Search Results</font></p>
    <%
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\Game Emporium.mdb"))


    search = Trim(Request.Form("search"))
    sSQL= "SELECT * FROM Game WHERE (Game_title LIKE '%search%')"
    set oRS = oConn.Execute(sSQL)

    Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-family:arial; font-size:8pt;'>")
    Response.Write("<tr bgcolor=black style='color:white;'>")
    Response.Write("<td>Game_id</td>")
    Response.Write("<td>Game_platform</td>")
    Response.Write("<td>Game_title</td>")
    Response.Write("<td>Game_price</td>")
    Response.Write("<td>Game_Qty</td>")

    Do While NOT oRS.EOF
    Response.Write("<tr><td>" & oRS("Game_id") & "</td></tr>")
    Response.Write("<td>" & oRS("Game_platform") & "</td>")
    Response.Write("<td>" & oRS("Game_title") & "</td>")
    Response.Write("<td>" & oRS("Game_price") & "</td>")
    Response.Write("<td>" & oRS("Game_Qty") & "</td>")
    oRS.MoveNext
    Loop
    Response.Write("</table><br><br>")

    oConn.Close
    Set oRS = Nothing
    Set oConn = Nothing
    %>
    </html>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    the new code you gave me there gives me :

    ADODB.Fields error '800a0cc1'

    Item cannot be found in the collection corresponding to the requested name or ordinal.

    /rivolinho/search1.asp, line 70


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    replace line 70 with this:

    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>

    or replace the entire code with this:

    <%@LANGUAGE=&quot;VBSCRIPT" CODEPAGE="1252"%>
    <%response.buffer = true%>
    <%
    Dim SearchParam
    SearchParam = Trim(Request("SearchParam"))

    Dim CompType, t3_advSearch_String
    'Store type of query in CompType ie All Words/OR, Any Word/AND or Exact Phrase/EXACT
    CompType = Request("CompType")
    SearchColumn = "Game_title"

    SearchField = "zzz"
    if(Request("SearchParam") <> "") then SearchField = Request("SearchParam")
    'Remove any single quotes from search field to eliminate potential errors.
    SearchField = Replace(SearchField, "'", "")
    SearchField = Replace(SearchField, " ", " ")

    'Checks the CompType, Executes this code if the option All words or Any Word is chosen
    if(CompType <> "EXACT") then
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%"
    'Splits the search criteria into seperate words and stores them in an Array
    SearchArray=Split(SearchField," ")
    for i = 0 to Ubound(SearchArray)
    if i > 0 then
    'Builds the sql statement using the CompType to substitute AND/OR
    t3_advSearch_String = t3_advSearch_String & " " & CompType & " " & SearchColumn & " LIKE '%"& SearchArray(i) & "%'"
    else
    'Ends the sql statement if there is only one word
    t3_advSearch_String = t3_advSearch_String & SearchArray(i) & "%' "
    end if
    next

    else
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%" & SearchField & "%' "
    end if

    Dim rsSearch__t3_String
    'rsSearch__t3_String = "WHERE ID=1"
    if (t3_advSearch_String <> "") then rsSearch__t3_String = t3_advSearch_String

    set rsSearch = Server.CreateObject("ADODB.Recordset")
    rsSearch.ActiveConnection =("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\Game Emporium.mdb") & ";Persist Security Info=False")
    rsSearch.Source = "SELECT * FROM Game " + Replace(rsSearch__t3_String, "'", "'")
    rsSearch.CursorType = 0
    rsSearch.CursorLocation = 2
    rsSearch.LockType = 1
    rsSearch.Open()
    rsSearch_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <form name="search" id="search" method="get" action="search1.asp">
    <br />
    <br />
    <input name="SearchParam" type="text" class="btn" id="SearchParam" value="<%=UCase(Trim(Request("SearchParam")))%>" size="45" />
    <select name="CompType" class="TEXTAREA" id="CompType">
    <option value="<%=Request("CompType")%>" selected="selected"><%=Request("CompType")%></option>
    <option value="OR">All Words</option>
    <option value="AND">Any Word</option>
    <option value="EXACT">Exact Phrase</option>
    </select>
    <input name="Search" type="submit" class="btn" id="Search" value="Search" />
    </form>
    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    i tink im error prone or something, it given me :
    ADODB.Field error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    /rivolinho/search1.asp, line 70


    but when i enter fifa it give me back up
    -Fifa 2004


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    you have to write a clause there to show only if the rsSearch is not empty:

    Replace line 70 - > <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li> with this

    <%if (rsSearch.Fields.Item("Game_title").Value) <> "" Then%>
    <%
    Do While NOT rsSearch.EOF
    %>
    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>
    <%
    rsSearch.MoveNext
    Loop
    %>
    <% end if%


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    ADODB.Field error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    /rivolinho/search1.asp, line 70


    another snag to kill me!


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    sorry man, you have me going mad at the moment. is very complicated to work with a database that does not exist on my computer.
    I am also working on a project and trying to help you as well.

    Replace the last line I gave you with this:

    <% If Not rsSearch.EOF Or Not rsSearch.BOF Then %>
    <%
    Do While NOT rsSearch.EOF
    %>
    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>
    <%
    rsSearch.MoveNext
    Loop
    %>
    <% End If ' end Not rsSearch.EOF Or NOT rsSearch.BOF %>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    louie i think ill let you go after this, ive been killing you all day, thanks a million though,

    Microsoft VBScript compilation error '800a03fb'

    Expected 'Loop'

    /rivolinho/search1.asp, line 83


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    send a copy of that page


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    <%@LANGUAGE=&quot;VBSCRIPT" CODEPAGE="1252"%>
    <%response.buffer = true%>
    <%
    Dim SearchParam
    SearchParam = Trim(Request("SearchParam"))

    Dim CompType, t3_advSearch_String
    'Store type of query in CompType ie All Words/OR, Any Word/AND or Exact Phrase/EXACT
    CompType = Request("CompType")
    SearchColumn = "Game_title"

    SearchField = "zzz"
    if(Request("SearchParam") <> "") then SearchField = Request("SearchParam")
    'Remove any single quotes from search field to eliminate potential errors.
    SearchField = Replace(SearchField, "'", "")
    SearchField = Replace(SearchField, " ", " ")

    'Checks the CompType, Executes this code if the option All words or Any Word is chosen
    if(CompType <> "EXACT") then
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%"
    'Splits the search criteria into seperate words and stores them in an Array
    SearchArray=Split(SearchField," ")
    for i = 0 to Ubound(SearchArray)
    if i > 0 then
    'Builds the sql statement using the CompType to substitute AND/OR
    t3_advSearch_String = t3_advSearch_String & " " & CompType & " " & SearchColumn & " LIKE '%"& SearchArray(i) & "%'"
    else
    'Ends the sql statement if there is only one word
    t3_advSearch_String = t3_advSearch_String & SearchArray(i) & "%' "
    end if
    next

    else
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%" & SearchField & "%' "
    end if

    Dim rsSearch__t3_String
    'rsSearch__t3_String = "WHERE ID=1"
    if (t3_advSearch_String <> "") then rsSearch__t3_String = t3_advSearch_String

    set rsSearch = Server.CreateObject("ADODB.Recordset")
    rsSearch.ActiveConnection =("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\Game Emporium.mdb") & ";Persist Security Info=False")
    rsSearch.Source = "SELECT * FROM Game " + Replace(rsSearch__t3_String, "'", "'")
    rsSearch.CursorType = 0
    rsSearch.CursorLocation = 2
    rsSearch.LockType = 1
    rsSearch.Open()
    rsSearch_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <form name="search" id="search" method="get" action="search1.asp">
    <br />
    <br />
    <input name="SearchParam" type="text" class="btn" id="SearchParam" value="<%=UCase(Trim(Request("SearchParam")))%>" size="45" />
    <select name="CompType" class="TEXTAREA" id="CompType">
    <option value="<%=Request("CompType")%>" selected="selected"><%=Request("CompType")%></option>
    <option value="OR">All Words</option>
    <option value="AND">Any Word</option>
    <option value="EXACT">Exact Phrase</option>
    </select>
    <input name="Search" type="submit" class="btn" id="Search" value="Search" />
    </form>
    <%if (rsSearch.Fields.Item("Game_title").Value) <> "" Then%>
    <%
    Do While NOT rsSearch.EOF
    %>
    <% If Not rsSearch.EOF Or Not rsSearch.BOF Then %>
    <%
    Do While NOT rsSearch.EOF
    %>
    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>
    <%
    rsSearch.MoveNext
    Loop
    %>
    <% End If ' end Not rsSearch.EOF Or NOT rsSearch.BOF %>


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    <%@LANGUAGE=&quot;VBSCRIPT" CODEPAGE="1252"%>
    <%response.buffer = true%>
    <%
    Dim SearchParam
    SearchParam = Trim(Request("SearchParam"))

    Dim CompType, t3_advSearch_String
    'Store type of query in CompType ie All Words/OR, Any Word/AND or Exact Phrase/EXACT
    CompType = Request("CompType")
    SearchColumn = "Game_title"

    SearchField = "zzz"
    if(Request("SearchParam") <> "") then SearchField = Request("SearchParam")
    'Remove any single quotes from search field to eliminate potential errors.
    SearchField = Replace(SearchField, "'", "")
    SearchField = Replace(SearchField, " ", " ")

    'Checks the CompType, Executes this code if the option All words or Any Word is chosen
    if(CompType <> "EXACT") then
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%"
    'Splits the search criteria into seperate words and stores them in an Array
    SearchArray=Split(SearchField," ")
    for i = 0 to Ubound(SearchArray)
    if i > 0 then
    'Builds the sql statement using the CompType to substitute AND/OR
    t3_advSearch_String = t3_advSearch_String & " " & CompType & " " & SearchColumn & " LIKE '%"& SearchArray(i) & "%'"
    else
    'Ends the sql statement if there is only one word
    t3_advSearch_String = t3_advSearch_String & SearchArray(i) & "%' "
    end if
    next

    else
    t3_advSearch_String = "WHERE " & SearchColumn & " LIKE '%" & SearchField & "%' "
    end if

    Dim rsSearch__t3_String
    'rsSearch__t3_String = "WHERE ID=1"
    if (t3_advSearch_String <> "") then rsSearch__t3_String = t3_advSearch_String

    set rsSearch = Server.CreateObject("ADODB.Recordset")
    rsSearch.ActiveConnection =("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\Game Emporium.mdb") & ";Persist Security Info=False")
    rsSearch.Source = "SELECT * FROM Game " + Replace(rsSearch__t3_String, "'", "'")
    rsSearch.CursorType = 0
    rsSearch.CursorLocation = 2
    rsSearch.LockType = 1
    rsSearch.Open()
    rsSearch_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <form name="search" id="search" method="get" action="search1.asp">
    <br />
    <br />
    <input name="SearchParam" type="text" class="btn" id="SearchParam" value="<%=UCase(Trim(Request("SearchParam")))%>" size="45" />
    <select name="CompType" class="TEXTAREA" id="CompType">
    <option value="<%=Request("CompType")%>" selected="selected"><%=Request("CompType")%></option>
    <option value="OR">All Words</option>
    <option value="AND">Any Word</option>
    <option value="EXACT">Exact Phrase</option>
    </select>
    <input name="Search" type="submit" class="btn" id="Search" value="Search" />
    </form>

    <% If Not rsSearch.EOF Or Not rsSearch.BOF Then %>
    <%
    Do While NOT rsSearch.EOF
    %>
    <li><%=(rsSearch.Fields.Item("Game_title").Value)%></li>
    <%
    rsSearch.MoveNext
    Loop
    %>
    <% End If ' end Not rsSearch.EOF Or NOT rsSearch.BOF %>
    </body>
    </html>
    <%
    rsSearch.Close()
    Set rsSearch = Nothing
    %>


  • Registered Users, Registered Users 2 Posts: 202 ✭✭bribren2001


    it works!! great stuff,thanks alot louie,il write to your boss demanding you get a payed week off!

    id say youll need it after goin through that never ending problem code!


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    I am glad it's all working.


Advertisement