Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Appending string in asp

Posted on 2006-12-01
4
Medium Priority
?
1,892 Views
Last Modified: 2012-06-27
Greeting,

I have the following format in a table.

ID   Desc
--    -----
1     this is
2     a
3     test

what I want to have is a string="this is a test". Basically, use the select statement then append the Desc field.   the ID can be null or up to any number.

thanks.

0
Comment
Question by:mrong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
alsaan earned 240 total points
ID: 18056503
Dim rsData, string
Set rsData = Server.CreateObject("ADODB.Recordset")

rsData.Open "SELECT desc FROM table ORDER BY id;", connstring

While Not rsData.EOF
    string = string & rsData("desc")
    rsData.EOF
Wend

Set rsData = Nothing
0
 
LVL 2

Expert Comment

by:alsaan
ID: 18056522
Um... the second "rsData.EOF" actually should be "rsData.MoveNext"

Greets
0
 
LVL 3

Expert Comment

by:Masoudgh
ID: 18056707
alssam's code is right but forget " "
string = string & " " & rsData("desc")
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 160 total points
ID: 18082456
Some minor corrections:

Dim rsData, Value               'String is a keyword
Set rsData = Server.CreateObject("ADODB.Recordset")

rsData.Open "SELECT desc FROM table ORDER BY id;", connstring
Value = ""
While Not rsData.EOF
    If Not IsNull(rsData("desc")) Then
       If Len(rsData("desc")) > 0 Then
          If Len(Value) > 0 Then
              Value = Value & " "
          End If
          Value = Value & rsData("desc")
       End If
     End if
    rsData.MoveNext                            ' MoveNext here
Wend
rsData.Close
Set rsData = Nothing
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question