Solved

Appending string in asp

Posted on 2006-12-01
4
1,882 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 information …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now