Solved

Appending string in asp

Posted on 2006-12-01
4
1,888 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 60 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 40 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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