Wednesday, December 07, 2005
I ran across this code today.  This would be a good example of how NOT to dispose a dialog form.  It seems that "someone" though it would be a good idea to dispose the form only when an exception occurred?!?  Genius.  Unfortunately, I was the genius.  I should really watch my caffeine consumption!  Oh well, it's good to laugh at your own "creativity" once in a while... right? :-P

Dim frm As MyForm

Try
   frm = New MyForm
   With frm
      .StartPosition = FormStartPosition.CenterParent
      .Width = 650
      .Height = 600
      .ShowDialog()
   End With

Catch ex As Exception 'this should "probably" be "finally"
   If Not frm Is Nothing Then
      frm.Dispose()
   End If

End Try
Wednesday, December 07, 2005 11:48:13 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 

Ken McNamee has been thinking outside the SQL box.  I didn't realize that you can use a "case" statement in the "order by" clause:


DECLARE @orderBy varchar(50)
SET @orderBy = 'LastName'

SELECT
    *
FROM
    Employees
ORDER BY
    CASE
        WHEN @orderBy = 'LastName' THEN LastName
    END,
    CASE
        WHEN @orderBy = 'HireDate' THEN HireDate
    END

For more on this, see his post:
http://blogs.vertigosoftware.com/kenm/archive/2005/12/06/Dynamic_ORDER_BY_Clause.aspx

Wednesday, December 07, 2005 3:58:29 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, December 05, 2005

Jeff Atwood recently posted a list of windows tips and tricks on his blog.  The list included using Ctrl+C to copy the text out of message boxes.  This trick has been invaluable to me for a while, especially in place of "can you send me a screen shot of that?" 

But here's the kicker: Who knew that you could Ctrl-Click the taskbar to select multiple items and then perform actions (e.g. cascade,tile,close) on your selection?  Where have I been?  Jeff, you're the man.

Tuesday, December 06, 2005 6:52:48 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [2]  | 
 Thursday, December 01, 2005

When working with UserControls in VS, you can easily get yourself is a "crash loop."  The problem is that while debugging, your UserControl takes down VS.  When you re-open the solution, your buggy code runs again and again crashes the process.  It's difficult to fix the problem when VS keeps crashing, isn't it?

The fix is simple: go out to the file system and delete the .suo file.  Next time the solution is brought up, no solution documents will be displayed by default.  You can now fix the problem, but be careful not to use the designer until the underlying problem is fixed.  Using the designer before the code is fixed could expose you do another crash loop.

Thursday, December 01, 2005 7:39:19 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |