Posts
119
Comments
115
Trackbacks
22
December 2006 Entries
Bransky's Law

I've come up with a new law, like Murphy's Law or Godwin's Law, and named it after myself, at least until I come up with a more interesting or more amusing law.

Bransky's Law:  If you throw some wires together, they will become tangled beyond what you think should be possible.

posted @ Friday, December 29, 2006 4:16 PM | Feedback (0)
.Net and animated GIFs in Windows forms

Apparently when you use an animated GIF as a background image in a control (e.g. button or picturebox), the image lacks animation, i.e. it just sits there with its starting layer.  This is kind of annoying, but I was able to work around it in this particular instance by using PictureBox.Image.  I suppose if I were really desperate I could have used Thread.Sleep with a bunch of different images on rotation to make it look like an animated GIF.

posted @ Monday, December 18, 2006 10:32 PM | Feedback (1)
recycle those trees!

Here's some great info from Mother Earth Living:

5 Ways to Recycle Your Christmas Tree

by Tabitha Alterman, Mother Earth News Associate Editor

For many of us, decorating a Christmas tree is our favorite part of
the holiday season. If you're one of the more than 30 million people
who put up a live tree this year, you might want to consider extending
its usefulness once the season ends. Instead of tossing your perfectly
shaped pine or fir into the garbage where it will only end up in a
landfill, try one of these creative recycling avenues:

1. Throw it in the water. Christmas trees make great habitat for fish.
Just toss it in your pond or stream. If you don't happen to have a
fishin' hole on your property, contact local conservation groups. In
many areas, they'll pick up the tree and toss it into an appropriate
pond or stream for you.

2. Keep it on your land. Trees can provide lodging for all kinds of
critters besides fish. If you have a suitable place on your property
to let a tree decompose, it can become a nursery to insects, fungi and
possibly even amphibians and reptiles. Or consider keeping it in its
stand and placing it out of doors as a bird sanctuary; it will provide
our feathered friends much-needed protection from wind and cold. You
can even enjoy a second round of decorating by adorning the tree with
enticing bird food:

    * Suet smeared in the branches
    * Pine cones coated with peanut butter and bird seed, then hung from
branches
    * Strings of popcorn, cranberries or raisins wrapped around the tree
    * Hanging fruit slices

3. Use it in the garden. Trim branches off and place them over
perennial beds to reduce frost heaving caused by freezing and thawing.
Then use the trunks to create sturdy, homemade trellises or tomato
stakes.

4. Toss it in the stove. Use a few dry branches as kindling to start
your fires.

5. Keep it in your community. Many communities have tree recycling
programs that turn everyone's old trees into valuable mulch. If you
are unable to try any of the above ideas, contact your Public Works
Department to find out if they will collect trees curbside or from a
central drop-off location. Or visit Earth911.org
(http://www.earth911.org/usa/master.asp?s=misc&a=misc/xmas/treecycle.html)
to find a local tree recycler.

posted @ Tuesday, December 12, 2006 11:32 PM | Feedback (0)
casting SQL parameters

A coworker and I discovered the other day that we got an error when we tried using CAST on a parameter in the same line as the procedure call.  For example:

EXEC [procname] @param1, CAST(@param2 AS DATETIME)

result: Invalid syntax near 'cast'.

That statement didn't work till we separated it into two lines, like so:

SET @param2 = CAST(@stringdatevar AS DATETIME)

EXEC [procname] @param1, @param2

I haven't been able to google up any proof that the first call should cause an error, so it would be greatly appreciated if somebody could drop me a link.

posted @ Tuesday, December 12, 2006 8:41 PM | Feedback (0)
SET NOCOUNT ON with ASP.Net?

I'm curious what percentage of developers use SET NOCOUNT ON in their stored procedures on a regular basis, particularly when they don't know exactly what code (particularly ASP.Net code) will be used to call the procedure.  My general practice has been to not use it just because I don't know when my fellow coders will use SQLDataReader.RecordsAffected or SQLDataAdapter.Update() (thanks again Jon), but I often wonder if I should just always include it and then just change it when I get a complaint.  That could be problematic though, since the coder calling the proc could spend hours trying to get things to work before he or she realizes that the proc purposely isn't sending the count.

Thoughts anyone?

posted @ Tuesday, December 12, 2006 7:57 PM | Feedback (0)
unknown chars in SQL Server

I imported a text file into SQL Server 2005 today and ended up with squares at the end of the last column.  Turns out the text file, despite being tab delimited, had a tab prior to CR/LF at the end of each row.  I was confused at first as to how to get rid of the squares, but then I figured it out.

SELECT ASCII(RIGHT(column,1)) FROM table  --gives 9, which is TAB in the ASCII table

UPDATE table SET column = REPLACE(column, CHAR(9), '')  --replaces tabs with nothing

 

 

posted @ Monday, December 11, 2006 4:21 PM | Feedback (0)
Google is scary?

This is a very interesting article about how Google knows your every move:  http://www.motherjones.com/news/feature/2006/11/google.html

I don't think there's proof that Google has done anything completely crazy yet (depending on your stance on China and the whole bit), but I can see a day when, for example, somebody says they have proof that a candidate for president searched for "join communist club" or something controversial like that, when really the candidate's eighth cousin was using the computer that day.  Maybe some day there will be an open-source version of Google, where advertising doesn't matter, and searches don't get tracked along with personal information.

 

posted @ Friday, December 08, 2006 10:59 PM | Feedback (2)
Google is weird
I just remembered something annoying that happened yesterday.  I can't remember what my search terms were, but I added a word to the search and got a greater number of results!  As far as I understand it, that should never happen.  I've contacted Google about this once, and they somehow fixed it the last time. 
posted @ Friday, December 08, 2006 9:17 PM | Feedback (0)
SQL Server 2005 service packs

It took me a month, but I finally figured out how to get SP1 for SQL Server 2005 installed on my test server: by installing SP2.  I was getting errors (something about Debug registry and some other stuff) from setup on the Database Engine upgrade for SP1.  So I tried going directly to SP2, and got a new error.  Turns out I had to delete the msi file from C:\Windows\Installer that was mentioned in the log file.  Not sure if that was the problem for SP1, but SP2 is cumulative, so whatever.

UPDATE Feb. 19, 2007: SQL Server 2005 SP2 RTM has been released!

posted @ Friday, December 08, 2006 9:10 PM | Feedback (0)
.Net console apps and \"

I discovered something weird with .Net console apps.  Say I have an app called testapp and want to run it from a command line like this:

C:\>testapp /s Server /f "C:\testfolder\testfile\" >output.txt

That won't work the way you might expect it to.  The framework doesn't treat \" (backslash followed by a double quote) the way it should (in my opinion) and so the last argument is "C:\testfolder\testfile\" >output.txt

I just throw up a message in my app telling the user not to end the path with \", for lack of a better solution.  Thanks to Jon Galloway for this:  http://weblogs.asp.net/jgalloway/archive/2006/09/13/Command-Line-Confusion.aspx&;title=Command+Line+Confusion

posted @ Friday, December 08, 2006 5:00 PM | Feedback (0)
bit fields in SQL Server 2005
Yesterday a coworker asked why she got an error when trying to enter a "1" in a bit column in a table in Management Studio.  I figured she must have entered an extra space or something.  I was wrong.  Turns out that in SQL Server 2005, at least when entering data using Management Studio, you have to enter true or false!  Who thought that was a good idea?  There must be something I'm not understanding.  Why Microsoft?!  Why must I type three or four extra characters?!  Why won't you let me be lazy?!
posted @ Friday, December 08, 2006 4:45 PM | Feedback (0)
Welcome to my blog!
Welcome to my blog, where I shall post my random thoughts on SQL Server, C#, VB, ASP.Net, and various other trucs (if you'll pardon my French).  By day I'm the resident SQL expert and occasional .Net programmer at a web design company in the Pacific Northwest.  By night I'm a musician, writer, video game enthusiast, and renewable energy advocate.
posted @ Friday, December 08, 2006 4:39 PM | Feedback (0)
News