How to create this string? Thank You.

Discussion in 'ASP .Net' started by Miguel Dias Moura, Dec 13, 2004.

  1. Hello,

    I am calling an ASP.NET / VB as follows:
    search.aspx?search=asp%20book%20london

    Then I create a string with the keywords like this:
    Dim keywords() As String =
    Request.QueryString("search").Split(CChar(""))

    It's not working. What am I doing wrong?

    I also need to create a new string. Something as follows:
    newString = "CONTAINS (*, 'keyword(1)') AND CONTAINS (*, 'keyword(2)')
    AND ... CONTAINS (*, 'keyword(i)')"

    I will need some kind of loop.

    Can someone tell me what am I doing wrong on first code line and how to
    create newString?

    Thanks,
    Miguel
    Miguel Dias Moura, Dec 13, 2004
    #1
    1. Advertising

  2. It looks like you are missing your space character in your split statement.

    Dim keywords as string()
    keywords = s.Split( CChar( " " ) )

    Here is a loop that will get you the result you are looking for.

    Dim query as String = String.Empty
    Dim i As Int32
    For i = 0 To keywords.Length
    query += String.Format("CONTAINS ( *, '{0}') ", keywords(i))
    If i + 1 = keywords.Length Then
    i = keywords.Length
    Exit For
    End If
    query += " AND "
    Next

    HTH,

    bill

    "Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
    news:...
    > Hello,
    >
    > I am calling an ASP.NET / VB as follows:
    > search.aspx?search=asp%20book%20london
    >
    > Then I create a string with the keywords like this:
    > Dim keywords() As String =
    > Request.QueryString("search").Split(CChar(""))
    >
    > It's not working. What am I doing wrong?
    >
    > I also need to create a new string. Something as follows:
    > newString = "CONTAINS (*, 'keyword(1)') AND CONTAINS (*, 'keyword(2)')
    > AND ... CONTAINS (*, 'keyword(i)')"
    >
    > I will need some kind of loop.
    >
    > Can someone tell me what am I doing wrong on first code line and how to
    > create newString?
    >
    > Thanks,
    > Miguel
    >
    William F. Robertson, Jr., Dec 13, 2004
    #2
    1. Advertising

  3. Hi,

    I tested your code but when I display the result I don't get anything.

    Here is the code I am using:

    Sub Page_Load(sender As Object, e As System.EventArgs)
    If Request.QueryString("search") Is Nothing Then
    Else
    Dim keywords as string()
    keywords = Request.QueryString("search").Split(CChar(" "))
    Dim query as String = String.Empty
    Dim i As Int32
    For i = 0 To keywords.Length
    query += String.Format("CONTAINS ( *, '{0}') ", keywords(i))
    If i + 1 = keywords.Length Then
    i = keywords.Length
    Exit For
    End If
    query += " AND "
    Next
    Response.Write(query)
    End If
    End Sub

    I called the page like this:
    page.aspx?search?asp%20book%20london

    Am I doing something wrong here?

    Thanks,
    Miguel

    "William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
    news:theman_at_fdrsucks.com:
    > It looks like you are missing your space character in your split
    > statement.
    >
    > Dim keywords as string()
    > keywords = s.Split( CChar( " " ) )
    >
    > Here is a loop that will get you the result you are looking for.
    >
    > Dim query as String = String.Empty
    > Dim i As Int32
    > For i = 0 To keywords.Length
    > query += String.Format("CONTAINS ( *, '{0}') ", keywords(i))
    > If i + 1 = keywords.Length Then
    > i = keywords.Length
    > Exit For
    > End If
    > query += " AND "
    > Next
    >
    > HTH,
    >
    > bill
    >
    > "Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
    > news:...
    > > Hello,
    > >
    > > I am calling an ASP.NET / VB as follows:
    > > search.aspx?search=asp%20book%20london
    > >
    > > Then I create a string with the keywords like this:
    > > Dim keywords() As String =
    > > Request.QueryString("search").Split(CChar(""))
    > >
    > > It's not working. What am I doing wrong?
    > >
    > > I also need to create a new string. Something as follows:
    > > newString = "CONTAINS (*, 'keyword(1)') AND CONTAINS (*, 'keyword(2)')
    > > AND ... CONTAINS (*, 'keyword(i)')"
    > >
    > > I will need some kind of loop.
    > >
    > > Can someone tell me what am I doing wrong on first code line and how
    > > to
    > > create newString?
    > >
    > > Thanks,
    > > Miguel
    > >
    Miguel Dias Moura, Dec 13, 2004
    #3
  4. Hi,

    My mistake. I was using a ? instead of a = in the URL.

    Thank You Very Much for your help,
    Miguel

    "William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
    news:theman_at_fdrsucks.com:
    > It looks like you are missing your space character in your split
    > statement.
    >
    > Dim keywords as string()
    > keywords = s.Split( CChar( " " ) )
    >
    > Here is a loop that will get you the result you are looking for.
    >
    > Dim query as String = String.Empty
    > Dim i As Int32
    > For i = 0 To keywords.Length
    > query += String.Format("CONTAINS ( *, '{0}') ", keywords(i))
    > If i + 1 = keywords.Length Then
    > i = keywords.Length
    > Exit For
    > End If
    > query += " AND "
    > Next
    >
    > HTH,
    >
    > bill
    >
    > "Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
    > news:...
    > > Hello,
    > >
    > > I am calling an ASP.NET / VB as follows:
    > > search.aspx?search=asp%20book%20london
    > >
    > > Then I create a string with the keywords like this:
    > > Dim keywords() As String =
    > > Request.QueryString("search").Split(CChar(""))
    > >
    > > It's not working. What am I doing wrong?
    > >
    > > I also need to create a new string. Something as follows:
    > > newString = "CONTAINS (*, 'keyword(1)') AND CONTAINS (*, 'keyword(2)')
    > > AND ... CONTAINS (*, 'keyword(i)')"
    > >
    > > I will need some kind of loop.
    > >
    > > Can someone tell me what am I doing wrong on first code line and how
    > > to
    > > create newString?
    > >
    > > Thanks,
    > > Miguel
    > >
    Miguel Dias Moura, Dec 13, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    1
    Views:
    396
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 1, 2004
  2. Miguel Dias Moura
    Replies:
    1
    Views:
    419
    Lars Netzel
    Jun 18, 2004
  3. Miguel Dias Moura
    Replies:
    2
    Views:
    340
    Martin
    Jun 22, 2004
  4. Shawn
    Replies:
    8
    Views:
    386
    Shawn
    Sep 21, 2006
  5. PETER WONG F H (+971 50 8320722)

    Please send you property detail to me,thank you !

    PETER WONG F H (+971 50 8320722), Mar 14, 2010, in forum: Python
    Replies:
    0
    Views:
    316
    PETER WONG F H (+971 50 8320722)
    Mar 14, 2010
Loading...

Share This Page