If you ever encounter this error when compiling your C# program, don't be alarmed! Obviously, arithmetic operations ARE supported for decimal, double, etc... You're just not allowed to mix double/float and decimal in arithmetic operations.

For instance, the following code will generate the above error:

decimal val = 0.45M;
decimal result = 0.15 * val;
Just change the second line as shown below to get rid of the error:

decimal result = 0.15M * val;

Visual Studio 2008 Installation Problem

I recently got my hands on Visual Studio 2008 RTM (release to manufacturing - in other words, NOT in beta anymore) and set out to install it on my machine thinking it would be a matter of popping the DVD in, clicking through a couple of screens and leaving the installer alone do its thing while I took care of other things. Little did I know that there was a world of frustration in store for me.

I came back to check on the install after an hour or so to find out that the install had failed at the very early stages - specifically, the installation of the web authoring tool had failed because of an Office 2007 compatibility issue. So the first thing I did was perform a Google search for VS 2008 installation problems and I came across a number of sites (mainly MSDN newsgroup posts) containing user complaints related to VS 2008 installation issues. After trying a number of suggestions that turned out to be dead ends, I came across a site that provided the answer and a lesson in debugging: always look for log files when you encounter installation problems.

Here's the site:

http://www.hanselman.com/blog/Office2007WontUpgradeFromAPrereleaseVersio...

And here's a summary of the steps I took:

- Look in "C:\Documents and Settings\\Local Settings\Temp" for the most recent file of the form "SetupExe{...}.log".
- Look for the product code of the component that caused the failure. In my case it was embedded in the line: "Catalyst beta product conflict check failed. Office Beta product conflict is detected on the computer, productcode={40120000-00A8-0409-0000-0000000FF1CE}".
- Look in the registry for the GUID ({40120000-00A8-0409-0000-0000000FF1CE} in my case) that you find.
- Uninstall the product using Add/Remove programs.


Fetching Sorted Keys from a Hashtable

Here's a quick and dirty way to retrieve the keys of a hashtable (or generic Dictionary in this case) as a sorted list:
...

public static List<K> GetSortedKeys<K, V>(Dictionary<K, V> table)
{
   List<K> sortedKeys = new List<K>();

   foreach (K key in table.Keys)
   {
      int locIndex = sortedKeys.BinarySearch(key);

      Debug.Assert(locIndex < 0);

      sortedKeys.Insert(~locIndex, key);
   } // foreach

   return sortedKeys;
}

...

Adding or Updating Entries in a Lookup Table

I frequently come across situations where I need a way to insert a key/value pair into a lookup table or update it if it already exists. So I figured I’d write a stored procedure that would do the following things for me:

♦ Accept the lookup key and value as input arguments and return the unique id of the new (or existing) key that was just inserted (or updated) as an output argument.
♦ Correctly deal with race conditions where two separate entities (processes, threads, etc…) are trying to insert or update the same lookup key/value pair and accomplish this without using a transaction.

Quick Schema Viewer

Quick Schema Viewer is a helpful little Windows Forms application that I created while working on a project that required me to generate a lot of simple stored procedures. Here are a few highlights:

♦ Easily find tables and views in a (SQL Server 2000 or 2005) database containing many tables.
♦ Generate insert stored procs for all tables - even those with a large number of parameters.
♦ Quickly retrieve schema information for tables and views.

Minimum Requirements:

♦ Microsoft Windows XP/2003/Vista
♦ Microsoft .NET Framework 2.0
♦ SQL Server 2000/2005

 Free Download