Skip to content

MCPD

July 9, 2009

I realized there are a great number of things that I feel I should know but I do not regarding development within the .NET framework.  I know that certifications are often maligned among developers who feel they prove nothing and are just for the pointy-haired bosses but I think I stand to gain significantly through the studying even if I never take the exams.

That said, I WILL be taking the exams because that will motivate me to study and memorize more and the cost to me will be nothing.  My long term goal is the MCPD – EAD (Microsoft Certified Professional Developer – Enterprise Application Developer).  While I’m part of a relatively small team (1 main developer (me), 2 guys who help with reports but have other main duties and my boss/manager who is somewhat of a developer as well) I think this certification is the one that makes the most sense.  I may not get the last test that makes me an EAD but I need to solidify my base in both WebForms and WinForms apps as well as strengthen my abilities with ADO.NET in general.  If I will be taking all the other tests, hopefully by the time I get to that point I’ll be confident and ready to take the 565.

Anyway, here’s hoping.  I intend to post some of the tidbits I pick up while studying if I find them to be especially useful or I feel they’re undercovered (as in, in all my searching for .NET related stuff in the past, I hadn’t heard of whatever).

Link to the certification track requirements

Advertisements

Try/Finally and Connection Pooling

July 1, 2009

I had a BIG ‘no-duh’ moment this week. In fact I had a big reality check / wake-up call / whatever else you want to call it.

I wrote some horrible horrible horrible code that really was almost sinful in nature. So, first we’ll start with the (almost) forgivable mistake:

cn.connectionstring = “blah blah blah”
cmd.connection = cn
cn.open
‘database code here
cn.close

Okay… the problem there? No error handling… so if the ‘database code here’ chunk throws an error, we have a hanging connection and with connection pooling, that will hold up a resource for a LOOOOOOOOONG time.

Okay now for the even worse issue that I almost don’t want to admit:

cn.connectionstring = “blah blah blah”
cmd.connection = cn
cn.open
‘database code here

That is what I found in like 8 places in my code… no .Close called on ANY of the connections… what the heck?

The code is now fixed as it should have been done from the beginning:

cn.connectionstring = “blah blah blah”
cmd.connection = cn
cn.open
try
‘database code here
finally
cn.close
end try

Sorry for the somewhat useless spammy post but I was so mad at myself for doing either of these things… especially the latter… that I had to share.

Crystal Reports XI – Subreports within Subreports

June 25, 2009

You can’t do this. I honestly expected a little more. There is no way to do this and in my case it absolutely needs to be possible. I’m so frustrated right now at Crystal Reports; every day spent working with this tool take me one step closer to what I expect to be a final recognition that this is NOT an appropriate tool for anything more than basic reporting.

P.S. Their pie charts are pretty horrible too. Depending upon the length of the text items in your key, and the title of the chart, they will just step all over the pie chart, or shrink the pie chart down to less than an inch big… when the pie chart is the most important part… what the heck!?

SQL ISNULL

June 10, 2009

I know this is not a super-advanced topic.  I know this is not that difficult.  I just hope that if someone new to SQL is looking for help, this may provide exactly that.

I use this all the time and if you are new to SQL, this is an important thing to learn as NULL values can kill your queries.

Most recently, I had to take a first name from a table, a last name from a table, and join them together in reverse order using a comma as the delimiter. This is easy enough to do in SQL:

SELECT LastName + ‘, ‘ + FirstName FROM Table

This will return:

Petersen, Rick
Doe, John

If you don’t have a value in one of the fields however, this will blow up. Let’s say we didn’t know John’s last name… We might expect to at least see the row and get something like:

Petersen, Rick
, John

But instead, we will get:

Petersen, Rick

The null will disrupt the query. To get what I said we might have expected above, we would do:

SELECT ISNULL(LastName,’’) + ‘, ‘ + ISNULL(FirstName,’’) AS FullName FROM Table

ISNULL says, if it IS NULL, replace it with the value following… in this case the empty string… we will now get the expected result.

The issue I ran into was that we had many records, and in the large majority of them, both FirstName and LastName were NULL and I was using the above code, so we had records like:

Petersen, Rick
,
,
,
,
,
Doe, John
,
,

That looked horrible on the report, so I needed the commas to go away if the LastName field was NULL. This gets us into CASE statements which I think deserve their own post, but for here I’ll just gloss over them:

SELECT ISNULL(LastName,’’) + CASE ISNULL(LastName,”) WHEN ” THEN ” ELSE ‘, ‘ END + ISNULL(FirstName,’’) AS FullName FROM Table

This will make sure we get a record returned for every record in the database whether the names are null or not, and it will not return just a comma if the fields are blank. Otherwise you will get ‘LastName, FirstName’ in a column titled ‘FullName’.

Windows Mobile, Here I Come

June 3, 2009

Yesterday the idea was spitballed to me at work that we need a safety/QC Audit program that has a few features that none of the one out there seemingly have as well as many of the features they do have.  For those who do not know me, I am currently a 1-man development shop.  On top of that, I’ve never coded for a mobile device.  On top of that I ‘ve not coded in C++ in some 6-7 years.  Needless to say, I am both excited and a bit intimidated due to the scope of the project.  I will likely be posting my journey with this application here too.

SQL Query – 1 Column to 1 Record

June 3, 2009

I run into this somewhat frequently, and the answer is relatively simple… but every time I run into it, I start by searching for the fix… putting this here for my own benefit as much as anyone elses’.

If you have ever had a ‘Users’ table with an ‘Email’ column and wanted to send an email to all those users, this query will get you what you need:

DECLARE @EmailAddresses VARCHAR(MAX)
SELECT @EmailAddresses = COALESCE(@EmailAddresses +’;’,”) + Email FROM Users
SELECT @EmailAddresses

This will spit out a string that can be pasted into Outlook or any other email program that separates multiple recipients by semi-colon and will work.

Deploying Crystal Reports XI On IIS For Win2003

June 2, 2009

I will create posts at a later date to detail, or at least link to people who have, how to develop start to finish a Crystal Report against a SQL Server back end that can be viewed in an ASP.NET page hosted in IIS.  This post will, instead, focus on the ‘system requirements’ as it pertains to dll’s in order to be able to host such an application/report.  Every time I create one of these and push it to a server that has not been host to such a beast before, I run into the same issue and end up digging for way too long.

Read more…