C# Struct versus Class

2008 07 25 – 7:21 am
I've been working on an in-house inventory management system for the last few weeks. During the course of the project, I've been faced with a few design decisions that I thought would be nice to share here.As if the title weren't a dead giveaway, I've had to decide on using classes or structs for holding data I intend to output or input. So, basically, I needed a mechanism for hold values that I set once and then output to the screen or input to the database.The main difference between a struct and a class is the type of object they are. A struct is a value type where as a class is a reference type. This means that structs share the behavior of other value types such as int32, DateTime, etc. In effect, a struct will behave like any other variable you declare. Once ...

SQL Server 2008 Launching Next Week?

2008 07 03 – 8:33 pm
Back in early June, I attended the Microsoft Heroes Happen Here Launch event for Windows Server 2008, SQL Server 2008 and Visual Studio 2008. I was so excited about attending the event because of SQL Server 2008. Let me tell you, the scope of enhancements that have been made to the product since the 2005 version are as dramatic as those made between the 2000 and 2005 versions. One of the great things I saw at the event was the strides that SQL Server 2008 has made in the areas of business intellegence. Reporting Services have been beefed up quite a bit and the development tools have been tricked out to include some basic intellisense for Select statements. The product evangelist said that enhancements to the feature will be patched in later.But, why talk about SQL Server 2008 now? Apparently, there are rumors about ...

SmartPart for SharePoint

2008 06 27 – 11:25 pm
Recently, was charged with the not so awesome task ofwriting an interface for a planning group to use to relate budget performancemeasures with a separate more detailed model that breaks the measures into coreservices. Nonetheless, sounds simple andit is. The only thing that makes thisworth bringing up is that the one and only requirement was that it must bepresented in SharePoint. No problem! Right? One of the biggest things SharePoint 2007 promises is thatall your current ASP.Net coding skills are immediately transferable to use withSharePoint since it’s built on the .Net 2.0 Framework. Is this true? As it turns out… Yes.So what did I do? Iused a web user control. I basicallycreated a web part that loads a single web user control and did all my work inthe web user control. Is this the rightor the best way to accomplish the task? ...

SQL UDF to strip all Non Alpha-numeric Characters

2008 06 25 – 10:17 pm
A few days ago, I introduced a SQL user-defined function for stripping alphabetical characters from a varchar. Today I'd like to throw a little something something out there for stripping all non alpha-numeric characters from a varchar. Now, you may be wondering when you would use something like that, but there may come a time. My situation was that I had a developer who wanted what was stored as a comma delimited list to be returned as a string with no commas. Now, some of you may be thinking that the commas were there for the purpose of handling multi-character items, but hey. I was just the database guy for this little project. Regardless, I used the following user-defined function (UDF) to satisfy the request. CREATE FUNCTION [dbo].[fn_parseAlphaChars] ( @string varchar(max) ) RETURNS varchar(max) AS BEGIN declare @charPos int set ...

Utility for Painless Month Dropdowns in .NET

2008 06 20 – 11:15 pm
A former co-worker of mine and good friend Jeff Sargent posted a very useful article about creating a month dropdownlist in ASP.Net using C#. Rather than copy/paste, here is an excerpt from the article and a link to the full post. I’m a fan of having a utility class in my .NET solutionsto handle the bits of repeated functionality present throughout the projects. Today I found myself needing several day/month/year dropdowns in different controls, and decided I’d throw together a utility to return the months for me as numeric values, full month names, or abbreviated month names. It’s not rocket science, but someone may find this handy. For the full Article... JeffSargent.com: Utility for Painless Month Dropdowns in .NET

ScribeFire - Firefox Add-on for Blogging

2008 06 20 – 10:34 pm
After upgrading to FireFox 3.0 I went went ahead and installed the standard add-ons for a guy in my line of work like Web Developer toolbar and FireBug. But, could I possibly be writing a blog post about such old news? Of course not. Let me introduce you to ScribeFire!I was reading an article on TechCrunch that led me to an awesome tool called ScribeFire. ScribeFire is a blogging add-on that will connect to your blog software and allow you to publish content. This very post has been composed and researched using the ScribeFire interface. It supports multiple bloggs as well. So, if you happen to run or contribute to several blogs, ScribeFire will allow you to publish to each of them from the same interface. The best part is that it works independed of your browsing window and tabs. This means ...

SQL Server 2005 Strip Alphabetical Characters from a String

2008 06 18 – 10:28 pm
For anyone who has ever had to do funky things in SQL, you’ll probably appreciate this post. However, you may have already written something similar before. Oh well, I’m bored at the moment and feel like sharing this little user-defined-function (UDF) that makes use of the PATINDEX() function to strip alpha characters from a varchar string. Why would you need to strip the alphabetical characters from a string? In my scenario, departments and their division are stored in a single column and identified by a number to indicate department and a letter to indicate division (example: 15a = Information Services – Applications Division). Say you need to find out what department a division is a member of. All you need to do is strip the alpha characters from the string and you’re left with the department the division belongs to. Let me also throw it out there ...

Starting and Stopping Windows Services with C#

2008 06 16 – 8:38 pm
The other day I found myself needing to write a quick application to start and stop services on my desktop since I didn’t need them all running all the time. Specifically, I have a copy of the SQL Server 2008 CTP that I’m fooling around with and it is my observation that running the SQL Server services (even express edition) has an adverse affect on system performance on Windows Vista (pick your edition) system. So, rather than always opening the Administrative Tools and going through the Microsoft provided tools to start and stop services, I decided to embrace the learning opportunity and write a little app to handle it my self. For the purpose of this demonstration, we will get a list of all the services that are available on your machine and throw it into a DataTable. First thing’s first. You’ll need to add the System.Management and System.ServiceProcess libraries to your project. ...

Programming Interfaces in C#

2008 05 03 – 2:51 am
What is an Interface? An interface is a encapsulator, for lack of a better term (Its 2:30 am). It contains the signatures of methods, events or delegates. The best way for me explain a good use for an interface is through example. Say, you have a superclass that describes your object. This superclass contains properties that from it, all inherited classes will possess. Now say some of these properties or behaviors that every single inherited class will have to override because it needs to be slightly different. Enter the interface. Assume you have a finite array of behaviors that any of these inherited classes will need to override to. An interface can be used to implement these behaviors. So what does an Interface look like? Let me demonstrate using the hello world scenario. interface IHelloWorld { string HelloWorld(); } You notice, ...

My new Verizon Blackberry 8830

2008 02 28 – 11:42 pm
After a few months, I thought, "hey, I might as well dust off this blog thing and write something." So, to that extent, I picked up a Blackberry 8830 a couple weeks ago. I picked up the Blackberry Enterprise Server plan to go along with it so I could connect to my work exchange server. I must admit I know why folks get addicted to these things. I picked up some good applications that elevate the Blackberry from a nice-to-have tool to a can't-live-without device that controls your life.The list of apps... Google Talk - I downloaded this from mobile.blackberry.com. It is a must have. As far as I'm concerned, there is no better mobile instant messaging app available for the Blackberry. Mig33 Messenger - I picked this up from mig33.com. Mig33 is a service that sells sms and international voip calls. However, the ...