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 […]
Finding the username of the current Windows user with VB.NET
This single line of VB.NET code below will put the name of the current Windows user into the currentUserName variable:
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 […]
DataBinding: ‘System.Data.Common.DbDataRecord’ does not contain a property with the name x
This is a common error that occurs when you are trying to display a record in ASP.NET from a DataSource such as a SQL database, and a field you requested within the code cannot be found within the result returned by the DataSource. For example if you use a SQL command to retrieve fields, and […]
Getting remaining battery power and battery status using VB.NET
The following VB.NET will make use of the SystemInformation class in order to obtain the battery charge status in percentages and the current power source: AC power / battery charging or battery power / battery not charging.
In ASP .NET, how do I set the script timeout?
You can use the following property (value in seconds): Page.Server.ScriptTimeout = 60; Also using this property you can retrieve the current time-out.
How to redirect to a different page using Response.Redirect in ASP.NET
You only need to use a simple method for redirecting to an URL in ASP.NET: Response.Redirect(). In the example below we are redirecting to http://www.geekpedia.com: Response.Redirect(“http://www.geekpedia.com“); You don’t have to type an absolute URL if the file is located on the same server. In that case you can use relative paths: Response.Redirect(“NewFile.aspx”);
Get current screen resolution in VB.NET
To get the current screen resolution in VB.NET you can use the Bounds.Height and Bounds.Width properties as such:
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 […]