Just think a bit before asking a question: the issue is about the property
CommandText
, and you show a pretty big fragment of unrelated code, but not a single like showing the name
CommandText
! Do you think this is nice? Or can make any sense?
Find the problem by yourself, it's one of the easiest to find. You simply try to use this property when it's value is null. Find all places where you use it and put a breakpoint in the like before, run it under debugger and find out where the property is null before use. Accordingly, the fix will either make sure the property (the field behind) is initialized before use, or you check if for null before use and don't use it if it is null (don't try to de-reference the null reference).
Now, I don't believe a more or less big application written in such manner can ever work. Look, you have written the literal "Consultant" at least 3 times, as well as other immediate string constants. This is opposite to what is called programming. Do you think such things can be supported? You will get lost in early stages of development. Please see:
http://en.wikipedia.org/wiki/Don%27t_repeat_yourself[
^].
—SA