Archive for the ‘c#’ Category

Numeric String Sort in C#

Thursday, June 2nd, 2011

Scenario: you have a List<string> collection where the contents could be alpha, numeric, or alphanumeric. If you just sort the collection using the built-in Sort() method, it will use string.CompareTo(), treating each item in the collection as a string. Thus a collection with the following values ["1", "44", "22", 4", ...

Connecting to Excel and Access Files using .Net on a 64-bit Server

Thursday, January 14th, 2010

If you are trying to query a MS Excel (.xls, .xlsx, .xlsb) or MS Access (.mdb, .accdb) file on a 64-bit server and are getting one of the following error messages: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. Then it ...

Casting vs. Converting in .Net

Thursday, December 11th, 2008

I recently saw a piece of code in a project that was throwing an exception that I did not understand: string boolString = (string)DataBinder.Eval(DataItem, "IsNew"); One would expect that boolString would be assigned the value "True" or "False" depending on the value of the IsNew property of the DataItem object. However, this ...

Detecting Application Idle State in Windows Forms

Thursday, February 7th, 2008

On a recent project, I had the need to detect whether or not the application is idle, and if so, for how long has the idle state persisted. Idle in my case is defined as no mouse movement or keyboard activity when any of the forms of the application are ...

Custom DateTime Format Strings for .Net

Thursday, November 15th, 2007

I have had to look up on DateTime formatting on MSDN so many times, I have lost track. So I am putting the links and some of the key information here for my own future reference.

Repeater Failure and Disappearance on Row 28

Thursday, August 2nd, 2007

I was working on an ASP.net application (1.1) the other day, changing the UI display of a page. This page basically consisted of a Repeater being populated with data from the DB, and binding javascript actions and styling info to the different rows to be output (each overall it was ...