June 24, 2015

I have this Sql table setup in Sql Server that contains a XML field and I need to count the number of times a xml node appears in the xml. In practice, it could be the table contains user data and the xml contains a list of cities the user has visited and we need to find out how many cities the user has visited.

June 19, 2015

I have sometimes seen WCF services that times out. The easiest way to fix it is to increase the timeout value within the config file. Here is an example of this can be done.

  1. <binding name="WSHttpBinding_ILoanService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">  
  2. </binding>

Okay, so there are four different timeouts - what do they mean.

How to Increase SQL Command Timeout

Sometimes I have seen while running a sql script from .NET code that the Sql Command times out. The solution is simple - we just need to increase the timeout. However, we should really think on why the timeout increase is needed and whether we should change the query - like, by reducing the number of rows returned - to minimise the time taken.

Before starting the discussion, what is Sql Command? It's a call to the database to get data or to update data. We can either directly execute the sql script or call a stored procedure by passing in the relevant parameters. In case, we figure we cannot change the sql query and our only option is to increase the timeout, then we can write the following code.

I was running an application using Visual Studio and for not so apparent reason the web service was not working. Since I was debugging the web site connecting to a web service within visual studio - it was not apparent as to why it was failing. When I started debugging the web service, I figured it resulting in an error - Memory gates checking failed because the free memory (296964096 bytes) is less than 5% of total memory.  As a result, the service will not be available for incoming requests.  To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element..

Practically there are no differences between int and System.Int32 (except while using enums). C# allows for certain aliases and it is one of those. Both int and System.Int32 are compiled to System.Int32 in the Intermediate Language (IL). C# contains a number of aliases that allows for quick typing of the variable types. Here is a full list of the aliases.

Reference: Shahed Kazi at AspNetify.com