0

I have a table full of data, I would like to know how i would be able to convert each of the rows in this data Table into a string using String builder. all i want to see on the string is the page name and the status.

|ID | PagenName |  error | Message | Status |
|1  | a         |  1     | tt      | failed |
|2  | a         |  1     | tt      | success|
|3  | a         |  1     | tt      | success|
|4  | a         |  1     | tt      | success|
2
  • 1
    Where is your source code? Can you paste? Commented Oct 17, 2013 at 11:54
  • 1
    Have you tried anything? Commented Oct 17, 2013 at 11:54

1 Answer 1

2

You can use Linq-To-DataSet to select what you need:

var data = From row in table
           Let PagenName = row.Field(Of String)("PagenName")
           Let Status = row.Field(Of String)("Status")
           Select String.Format("PageName: {0} Status: {1}", PagenName, Status)

If you want a single string, for example separated by Environment.NewLine:

Dim result As String = String.Join(Environment.NewLine, data)
Console.Write(result)

I would prefer such code because it's readable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.