Warning CA2000 is fired on a SqlCommand with many SqlParameters - by Harald Kogler

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 725836 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/20/2012 3:54:50 PM
Access Restriction Public


When using a method to create and return parameterized SQL-Queries, Visual Studio Code Analysis fires Warning:
CA2000 : Microsoft.Reliability : In method 'Class1.CreateInsertCommand()', call System.IDisposable.Dispose on object 'tmpCmd' before all references to it are out of scope. 

The warning is only fired after the parameter count exceeds a certain value. Please find attached a Demo-Project with which the issue can be reproduced.
Remove two or more arbitrary SQLParameter-adds to make the warning disappear.
Sign in to post a comment.
Posted by Microsoft on 5/10/2012 at 10:54 AM

Thank you for taking the time to report this. Unfortunately given current resource constraints we are unable to make fixes to individual code analysis rules at this point for either Visual Studio 2010 or Visual Studio 11; but will consider this for a future release after the upcoming Visual Studio 11 release.

Best Regards,
Visual Studio Code Analysis Team
Posted by Microsoft on 5/8/2012 at 2:51 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by Harald Kogler on 2/22/2012 at 3:11 AM
Rewritten this case in english.
Posted by MS-Moderator10 [Feedback Moderator] on 2/20/2012 at 8:26 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. At this time, we only provide support in the English language.

- For urgent issues, please contact support directly at http://support.microsoft.com or call 1-800-MICROSOFT for assistance.
Posted by MS-Moderator01 on 2/20/2012 at 4:42 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)