Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to create this string? Thank You.

Reply
Thread Tools

How to create this string? Thank You.

 
 
Miguel Dias Moura
Guest
Posts: n/a
 
      12-13-2004
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

 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      12-13-2004
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:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Miguel Dias Moura
Guest
Posts: n/a
 
      12-13-2004
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:(E-Mail Removed)...
> > 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
> >


 
Reply With Quote
 
Miguel Dias Moura
Guest
Posts: n/a
 
      12-13-2004
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:(E-Mail Removed)...
> > 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
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create this datagrid? Thank You. Shapper ASP .Net 0 06-20-2005 11:20 PM
How to create this dataset? Thank You. Shapper ASP .Net 1 06-18-2005 05:36 PM
How to create a 2 languages web site? Thank You. Shapper ASP .Net 10 04-25-2005 07:32 PM
Thank You CJ, Thank Mike! mytho Computer Support 7 11-23-2003 06:50 AM



Advertisments