Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a way to check if reader has multiple results
Message
 
 
À
01/08/2013 18:30:28
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01579688
Message ID:
01579694
Vues:
39
May be it's paranoia, but assuming the original ReturnMessage is quite long, this would be waste of resources. I am thinking may be I better off using a builder and just concatenate strings here instead?

I haven't run any performance tests yet, in fact, I'm deep in re-factoring today - I created a bunch of new classes and changing code to get rid of passing messages by reference around but rather re-use the new classes.


>Instantiating a StringBuilder won't take that much time. There is ReadAhead option available on Windows 8, but I don't see any way to know if there is more data.
>
>>Hi everybody,
>>
>>I know that NextResult() method of the SqlDataReader will get next result. However, is there a way to find out if SqlDataReader has multiple results or not?
>>
>>In particular, I have the following code
>>
>>
>> StringBuilder result = new StringBuilder(returnMessage);
>>
>>               while (sqlDataReader.NextResult())
>>               {
>>                  result.AppendFormat("\r\n{0}", GetFormattedReturn(sqlDataReader, returnType, out recordCount));
>>               }
>>               returnMessage = result.ToString();
>>
>>However, there is no need to create a new instance of the StringBuilder if the reader has only a single result set. I did a very quick google search and didn't find a way to find out by some property if the reader has multiple results.
>>
>>Do you know if there is such a property or there is another way to handle the above efficiently?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform