Sunday, June 26, 2011

Monetized my site

I monetized my site cause I am a poor bastard and maybe I can make a few cents, who knows. Wasn't really doing this to make money, but hell who knows what could happen in the future.

How to install sql server management studio 2008 component only

I posted an answer to this question on Stack Overflow here

Wednesday, June 22, 2011

Storing null in a Column will compile, but will cause run time exception

You can legally store a null in a column from a data row and the code will compile. Don't do this thought because it will definitely throw an exception during run time :)

dr["columnName"] = null; //This will throw an exception during run time

The remedy is to just use DBNull.Value:

dr["columnName"] = DBNull.Value; //This is legal

Friday, June 10, 2011


This is something that I don't do often, but it pops up every now and again. I always forget how to do it, so I have to look it up each time.

Here is an example:

UPDATE alias
 col1 = value,
 col2 = value,
 col3 = value
FROM table1 alias
 INNER JOIN table2 blah
  ON =
WHERE otherconditions

Thursday, June 9, 2011

Background goes white on post back

Have you ever been working on a web form or aspx page, then on post back the background color just turns white?

That is due to two different issues from what I have seen. One of which is if you have HTML tags that are not in the proper format or not closing in the right order.

For example:


If you have any of that going on, fix it immediately. It is wrong to begin with and just because HTML and things like it are usually dealt with very laxly doesn't mean it is okay to do it wrong. Every browser treats these kinds of mistakes differently.

The other problem that I have seen which is usually the main culprit is in the body tag. I don't know when this was okay to do, but it isn't supported anymore so it needs to be updated and stop doing it:

<body bottomMargin="0" bgColor="#ffffe0" leftMargin="0" topMargin="0" rightMargin="0" MS_POSITIONING="GridLayout">

The right way to do this is:

<body style="margin:0 0 0 0background-color:#ffffe0;">

This is a problem I keep running into while working on older sites etc...

Wednesday, June 8, 2011

++i vs. i++, YES they are different!

For this first test you will see that there isn't a difference, it is working differently, but you cannot tell the difference in this example:

public static void IncrementTest()
 for (int i = 0; i < 10; ++i)

 for (int i = 0; i < 10; i++)

This next example highlights the differences between i++ and ++i.

public static void IncrementTest2()
 int i = 0;
 Console.WriteLine("Initial Value: {0}\n", i);
 Console.WriteLine("Param i++ {0}", i++);
 Console.WriteLine("After Param i++ {0}\n", i);

 i = 0;

 Console.WriteLine("Param ++i {0}", ++i);
 Console.WriteLine("After Param ++i {0}\n", i);

 i = 0;

 Console.WriteLine("Statement i++ {0}\n", i);

 i = 0;

 Console.WriteLine("Statement ++i {0}\n", i);

Conclusion, be careful when writing code, don't assume that things work the same way when written differently.

Tuesday, June 7, 2011

DataTable.Compute() woes

So if you have ever seen this goddamn error before, then you might have been tempted to pull your hair out while screaming, "WHY WON'T THIS FUCKING WORK!" Especially when you see a goddamn example of it on the MSDN white pages:

For some people this is a very obvious error, "Oh stupid me, its so clear I am trying to take the sum of a column with a data type of string, oops!" But for people like me, when you are trying to get 100 things done all at the same time a stupid ass error like this can trip you up. So this is just a heads up on DataTables, make sure your DataTable's data is strongly typed so that you don't run into silly problems like this one.

Additionally when using the DataTable.Compute() method think of it this way: DataTable.Compute([Aggregate Function for ONE column only], [WHERE clause]), easiest way to think about it in my opinion. Keep it simple, no fancy stuff, this isn't real SQL.