Cause for ‘Failed to retrieve data for this request’ error in SQL Server 2005

When browsing the database list inside Microsoft SQL Server Management Studio, you may get the error below: Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum) Invalid column name ‘mirroring_role’.Invalid column name ‘mirroring_state’.Invalid column name ‘mirroring_state’. (.Net SqlClient Data Provider) One of the reasons for this error is that you are trying to connect to a […]

Which is the fastest way of checking if a string is empty?

There are many ways of checking if a string is empty, in C#: string myString = “”;if(myString == “”){   // String is empty} string myString = “”;if(myString.Length == 0){   // String is empty} string myString = “”;if(myString == String.Empty){   // String is empty} Performing benchmarks on these three methods resulted that the second method (myString.Length == 0) is almost three times faster […]

Use Debug.Assert to get Stack Trace information

Part of the System.Diagnostic namespace, Debug.Assert() is used to display the Call Strack Trace and it gives you three options – ‘Abort’, ‘Retry’ and ‘Ignore’. Basically when Debug.Assert() receives the boolean parameter false a dialog box pops up giving you details with Call Stack, and you can either end the program or continue.One example of where you can use Debug.Assert() is when checking if a […]

The name ‘Request’ does not exist in the current context

This error normally occurs when you are trying to access a property such as Request.Cookies and you’re not doing that from a webform, usercontrol or a class that inherits from System.Web.UI. Nothing to worry about, since you can still access these properties, but using a different path.For example to access a cookie with the name MyCookie you would normally […]