Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question SELECT CASE problems

    Hi,

    I am having problems to see the results using tha following statement:

    <%Do until rs.EOF%>


    <!--##################################-->

    <%Select Case Ubound(strKeyword)
    Case 0%>
    <%=response.write (rs.fields("english"))%>
    <%=response.write (rs.fields("castilian"))%>

    <%Case 1%>
    <%=response.write (rs.fields("english"))%>
    <%=response.write (rs.fields("french"))%>

    <%End Select%>

    <%Loop%>


    Could you please help me?

    Thanks

    JL

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Ubound is an array function to check subscripts.
    What is strKeyword?
    Perhaps you wanted Len to get the length of the string?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did a mistake: It is = <%Select Case strKeyword. no Ubound.

    Are 2 files: query.htm and search.asp

    The full script (search.asp) is (which not works fine)


    <%@ LANGUAGE=VBScript %>

    <%
    Option Explicit
    Response.Buffer = True
    Response.Expires = 0
    %>


    <HTML>
    <HEAD>
    <TITLE>Test</TITLE>
    </HEAD>
    <!-- SearchDb.asp-->

    <%
    ' ADO Constants - Don't Change Them
    Const adOpenForwardOnly = 0
    Const adLockReadOnly = 1
    Const adCmdText = &H0001
    Const adUseClient = 3
    %>
    <%
    Dim strDB, sSQL
    'set conn=server.CreateObject("adodb.connection")
    'conn.open "Provider=Microsoft.jet.oledb.4.0;data source="& server.MapPath("lexicum.mdb")

    strDB = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("lexicum.mdb")

    Dim currentPage
    If Len(Request.QueryString("currentPage")) = 0 Then
    currentPage = 1
    Else
    currentPage = CInt(Request.QueryString("currentPage"))
    End If

    Dim recordsToShow
    recordsToShow = 5

    ' Keyword/s to search

    Dim strKeyword
    strKeyword = Request.QueryString("look_for")


    Dim strlanguage
    ' strKeyword = split(Trim(Request.QueryString("look_for")), " ")
    strlanguage = Request.QueryString("lang")

    Server.ScriptTimeout = 6000

    Dim struser
    struser = Request.QueryString("users")





    ' Our Connection Object
    Dim con
    Set con = CreateObject("ADODB.Connection")
    con.Open strDB

    ' Our Recordset Object
    Dim rs
    Set rs = CreateObject("ADODB.Recordset")
    rs.CursorLocation = adUseClient
    rs.PageSize = recordsToShow
    rs.CacheSize = recordsToShow


    Select Case strKeyword
    ' Select Case UBound(STRkEYWORD)
    Case 0 rs.Open "select * from ec where english like '%" & strKeyword &"%' or castilian like '%" & strKeyword & "%'", con, adOpenForwardOnly, adLockReadOnly, adCmdText
    Case 1 rs.Open "select * from ef where english like '%" & strKeyword & "%' or french like '%" & strKeyword & "%' order by english desc", con
    Case 2 rs.Open "select * from ei where english like '%" & strKeyword & "%' and italian like '%" & strKeyword & "%' order by english desc", con
    Case Else rs.Open "select * from ep where english like '%" & strKeyword & "%' and portuguese like '%" & strKeyword & "%' order by english desc", con
    End Select
    %>

    <BODY>

    <!-- ##################################-->
    <%Do until rs.EOF%>


    <!--##################################-->

    <%Select Case strKeyword
    Case 0%>
    <%=response.write (rs("english"))%>
    <%=response.write (rs("castilian"))%>

    <%Case 1%>
    <%=rs("French")%>

    <%Case 2%>
    <%=rs("Italian")%>

    <%Case 3%>
    <%=rs("French")%>
    <%End Select%>

    <%Loop%>
    </BODY>
    </HTML>

    This script is running at: http://www.terminotics.com/query.htm
    Thank you for your interest.

    JanLee




    <!-- query.htm-->
    Last edited by JANLEE; 08-24-2005 at 03:49 PM.

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is "Request.QueryString("look_for")" returning a string or an integer? Your sql statements would lead me to believe that it is returning a string, but your select case statement would lead me to believe it's returning an integer. I suspect that it's coming from an input box on a previous screen, in which case you should change your select case statement.

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is the code of query.htm

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>

    <form method="get" action="search.asp">
    <input type="radio" name="look_for" value="0">English/Castilian<br>
    <input type="radio" name="look_for" value="1">English/French<br>
    <input type="radio" name="look_for" value="2">English/Italian<br>
    <input type="text" name="query" value="">
    <input type="submit">
    </form>


    </body>
    </html>



    It returns all records, instead the records that matching with input look_for.

    Thanks

    JanLee

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Those are actually strings, not integers.
    Change

    Case 0

    to

    Case "0"

    and so on.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Regular Coder
    Join Date
    May 2005
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.

    I will close this thread, although I had not solved my problem.

    Jan Lee


  •  

    Posting Permissions

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