Archive for January, 2006

SqlParameters and NULL values

This is just a tip about using SqlCommand objects with SqlParameters and null database values. Here’s one way to add a parameter to a command object:

SqlParameter param = sqlCmd.Parameters.Add(”@FirstName”, SqlDbType.VarChar);
param.Value = ‘ben’;

This adds a parameter named ‘FirstName’ with a datatype of ‘VarChar’ and a value of ‘ben’ to my SqlCommand.  Now, if you wanted to make the value of the parameter a null value, this is what I typically do:

SqlParameter param = sqlCmd.Parameters.Add(“@FirstName”, SqlDbType.VarChar);
param.Value = null;

Since the Value property of a parameter is of type System.Object, you can simply set it to null.  This is wrong.  Don’t do it.  You’ll get exceptions about missing parameters.  I ALWAYS forget this and I’m ALWAYS confused by the errors until I remember this.  If you set the parameter value to null, the SqlCommand must simply exclude the parameter when it executes, which would cause the missing parameter error.  Instead, this is how you set the value of a parameter to null:

SqlParameter param = sqlCmd.Parameters.Add(“@FirstName”, SqlDbType.VarChar);
param.IsNullable = true;
param.Value = System.DBNull.Value;

There is a special class ‘DBNull’ that is used to represent NULL values, so if you do it like the example above, you should be all set.

Trying Out Resharper

I’m trying out Resharper as I’ve heard many good things about it for quite some time. I’m about 2 weeks into my 30 day trial, and I do love the refactoring options it gives me, I especially love the feature where I can create a method on the fly and then Resharper will add the stub for me, very sweet.

One thing that annoys the hell out of me though, is that it doesn’t remember my preferences correctly. Every time I open VS (2003), I have to go into the Resharper options and tell it to use the VS Intellisense instead of the Resharper Intellisense. Has anyone else run into this, it really bugs me…………….

Got My Skype Phone!

Back in October I mentioned how I wanted this cordless Skype phone from LinkSys. Erin pulled through and got it for me for Christmas, in spite of its geekiness.  But, after explaining to her how she could call her friend who is moving to South Korea for next to nothing, she started taking a liking to it. After she makes a few calls to South Korea, I know she’ll like it even more.

As I said before, I really think that some form of VOIP will replace traditional phones at some point in the next few years.  VOIP is already used by many businesses, but they pay a lot of money to get such a system setup.  I’m talking about free or very inexpensive phone systems, like Skype.  I believe there are three major hurdles that have to be dealt with before Skype becomes mainstream.

  • The software needs to be hosted inside the phone itself
  • Wireless internet of some form (WiFi, WiMax, etc.) needs to be readily available throughout cities
  • Skype needs the ability to call emergency numbers like 911 reliably

Currently, you plug the phone into your computer with a USB cable, and run Skype on your desktop. Skype forwards the calls to the phone so you can place and recieve calls from the handset.  It would be much cooler if the software was on the phone itself, so I wouldn’t have to be running my computer in order to use the phone.  This would also require that the phone had wireless internet capability so that it could connect to the Skype service, which leads to the next point of city-wide wireless internet.

The Skype phone is cool enough as it is, but where it’s really going to shine is when my phone becomes mobile. This can’t happen until I can reliable get internet access all over the place. If cities install city-wide wifi, this would solve that infrastructure problem.  With Skype calls being so inexpensive, I can drop my cell phone plan completely, thus saving myself ~$40 a month.  I bet even at the current rates I would spend less than $10 a month on my Skype-Out calls (these are calls to a regular telephone number from your Skype phone), let alone the free calls to other Skype users as more people adopt the technology.

It is interesting to note that Skype doesn’t require its own infrastructure to be built like cell phone, landline phones, or cable companies. Skype just latches onto whatever internet connection you have, this is a big reason that usage will be able to rise so quickly, because people don’t need to wait for the service to get installed in their area. If you have internet access, you can use Skype.

The issue of dialing emergency numbers doesn’t have much to do with cool, sexy features, but it’s neccessary if people are going to ditch their cell phones and landline phones for Skype, they need to be able to contact emergency numbers, its non-negotiable.

I’m trying to remember to use the Skype phone whenever I’m at home, although it’s hard to not think of grabbing my cell phone first.  Every time a call gets dropped though, I definitely remember :)