Qustion regarding ASP.NET SQLDATAREADER

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

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...

G...
 
T

TDAVISJR

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top