How to create this string? Thank You.

M

Miguel Dias Moura

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
 
W

William F. Robertson, Jr.

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
 
M

Miguel Dias Moura

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
 
M

Miguel Dias Moura

Hi,

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

Thank You Very Much for your help,
Miguel
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top