With VB 6 and ADO 2.x I can't tell you how many times I wrote the following type of code and only realized what I had done after I had pressed F5:

 

The Infamous Infinite Loop Blunder
'--- Using VB 6 and ADO 2.x
oRs.Open
Do While Not oRs.EOF
    Debug.Print oRs(0)
Loop



Usually the moment after I ran this code I would realize that I was in an infinite loop. Then I would quickly put in the oRs.MoveNext just before the end of the loop and all would be well. Fortunately, in ADO.NET I no longer have this problem thanks to the DataReader and how it reads a record and moves the cursor to the next position all in one fell swoop. So .NET saved me from one of my most infamous blunders.

 

Using C# and ADO.NET
SqlDataReader oDr = oCmd.ExecuteReader();
while(oDr.Read())
{
    Console.WriteLine(oDr[0]);
}



But of course I didn't get off that easy. I now have all new mistakes to make with .NET. My most common mistake these days occurs when I declare a variable inside of a "try" block and then use it outside of the "try" block. For example, I'll do something along the lines of the foo method below:

 

Oops!public int foo(int y, int z)
{
    try
    {
        int x = y * z;
    }
    catch
    {
        // catch it here
    }
    // this will not compile!
    return x;
}


But at least with this mistake I catch it when I build my C# project. Then I move the declaration of the variable x outside of the try block and all is well.

OK, so now that I have opened up and shared some of my embarassing blunders, it's time for you to share some of your common blunders. Don't be shy!