Discussion in 'ASP .Net' started by msnews.microsoft.com, Apr 26, 2005.

  1. Hi

    Below is a code snippet that returns XML from SQL server... than I iterate
    to get all records that are appended to a StringBuilder object

    /** Pseudo Code **/
    SQLReader = SQLCommand.ExecuteReader ();

    while ( SQLReader.Read() )
    StringBuilder.Append ( SQLReader.GetValue ( 0 ) );

    return StringBuilder;

    /** End Pseudo Code **/

    Is there a better way to do it? All I need is to dump the result set in to
    StringBuilder object...

    Any ideas?

    Thanks in advanced...

    msnews.microsoft.com, Apr 26, 2005
    1. Advertisements

  2. msnews.microsoft.com

    TDAVISJR Guest

    Well to prevent boxing from happening you should use the
    SQLReader.GetString(0) since GetValue passess back an object (I think) and
    you do not want the StringBuilder to have to convert all of those values to
    a string datatype. Its just a performance thing. Otherwise, for your
    purposes, everything looks good.
    TDAVISJR, Apr 26, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.