Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to check if reader has multiple results
Message
 
 
To
02/08/2013 12:31:10
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01579688
Message ID:
01579780
Views:
38
>>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.
>
>Use StringBuilder. The teeny tiny efficiency you think you will gain (and I don't think there will be any) is not worth adding extra code.

And StringBuilder is over 300 times faster than its predecessor.
Previous
Reply
Map
View

Click here to load this message in the networking platform