Category Archives: .NET

SQL command always times out after 30 seconds

One of my query takes more than 30 seconds to run. Even I set the “Connection Timeout=120” in my connection string, it still throwing timed out exception. It turned out that the time out setting in the connection string is … Continue reading

Posted in .NET, SQL | Tagged | Leave a comment

C# String Format examples for Double

From http://www.csharp-examples.net/string-format-double/ The following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString. Digits after decimal point This example formats double to string with fixed number … Continue reading

Posted in .NET | Tagged , | Leave a comment

Caching with LINQ (“delayed” execution)

To increase the site performance, I cached (at least I thought I did) the result from a LINQ query into Application.Cache. The code is like this: public static List<Region> GetAllRegions() { if (MyCache.GetCache(“RegionListFromDB”) == null) { using (MyInfoDataContext db = … Continue reading

Posted in .NET, ASP.NET | Tagged | 1 Comment

OleDbCommand doesn’t support named parameters

When calling a parameterized stored procedure, if you pass parameters to a SqlCommand object (i.e. cmd.Parameters.AddWithValue(“@productID”, strProductID); cmd.Parameters.AddWithValue(“@productName”, strName); … ) SqlCommand will correctly map the value with the parameter regardless of the order these AddWithValue methods are called. However, … Continue reading

Posted in .NET, SQL | Leave a comment