C Sharp - Return dataset row as a string

Posted on 2012-09-10
Last Modified: 2012-09-10

I have the following line of code:  

tRow = dsSourceData.Tables(0).Rows(iCount)

I would like to return the row from this dataset to a string.  Can anyone help me?  Mere;y adding a .ToString at the end does not give me the result I am looking for.
Question by:Jasmin01
    1 Comment
    LVL 16

    Accepted Solution

    In datarow there could be more columns. You have one option.

    If you want particular column then you could use below code:

    this.mUsername = tRow ["Username"] as string;

    Or If you want entire row

    StringBuilder result = new StringBuilder();
    string seperator = "|";

    foreach(DataColumn dataColumn in myDataTable.Columns)
          result .Append(tRow[dataColumn].ToString().Append(seperator);

    string entirerowvalues = result.ToString();

    Please do refer and for more information.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now