# Friday, 07 September 2012

Sometimes I find myself applying the same formatting or performing the same task to many elements within a SQL Server Reporting Services (SSRS) report.

When this happens, I consider writing a reusable function to perform this task or formatting. Functions can be added directly to an SSRS report.

To add code to an SSRS report, open the report and select Report | Report Properties from the menu. The Report Properties dialog displays. Select the Code tab to bring this tab forward (Fig. 1).


Fig 1: The Code tab of the SSRS Report Properties dialogue

This tab contains a single edit box into which you can type Visual Basic code. The editor is very limited in that you can only use Visual Basic (no C#, F#, or JavaScript), and it provides no IntelliSense. Still, it does allow you to create functions that can be called elsewhere within your report. Type your function within this edit box.

Note: If, like me, you are having trouble writing valid code with the IntelliSense or other syntax-checking, It might be helpful to create a console application in Visual Studio and type the same function in order to validate the function's syntax and functionality.

In SSRS, you assign an expression to an object’s property using the Expression Editor (Fig. 2)


Fig2: The SSRS Expression Editor

In an Expression editor of any object on the report, you can call the function with the word "Code", followed by ".", followed by the name of the function.

For example, I found that I had a number of textboxes that displayed numeric data. I wanted every number to display with the following rules:

  • Format the numeric output so exactly 2 digits appear to the right of the decimal point
  • Print "N/A" for null values.

I could accomplish this by doing the following:

  1. Set the formatting of every textbox to "##,##0.00;(##,##0.00)"
  2. Change the expression in each textbox to something like:
    =Iif(IsNothing (Fields!Price), "N/A", Fields!Price)

But this is inefficient because one needs to perform the above steps for every textbox where this change is needed.

Instead, I created the following function and embedded it into the report:

Public Shared Function FormatAs2Digits(ByVal input as Nullable( of decimal)) as string
    return Iif(IsNothing (input), "N/A", Format(input, "##,##0.00;(##,##0.00)"))
End Function

Then, I could set the expression of each textbox to something similar to the following

=Code.FormatAs2Digits(Fields!Price)

Be aware that your report runs under a specific user context and that user will likely have very limited access rights, so your functions will be limited in what that user context can do. Generally, I only use functions to format data and perform other tasks encapsulated within the report.

Despite its limitations, an embedded function is an excellent way to create reusable code and consume it in multiple objects within an SSRS report.

Friday, 07 September 2012 21:19:29 (GMT Daylight Time, UTC+01:00)
# Monday, 03 September 2012
Monday, 03 September 2012 17:29:02 (GMT Daylight Time, UTC+01:00)
# Tuesday, 28 August 2012

Here is Randy Pagels's presentation on What's New in Visual Studio 2012at the August 2012 Great Lakes Area .NET User Group meeting.

Tuesday, 28 August 2012 06:14:01 (GMT Daylight Time, UTC+01:00)
# Monday, 27 August 2012
Monday, 27 August 2012 23:54:00 (GMT Daylight Time, UTC+01:00)
# Thursday, 23 August 2012

The organizers of That Conference knew a good thing when they saw it. For years, CodeMash has set the standard for community technical events. And when community leaders from Illinois and Wisconsin saw the success of CodeMash and experienced how well it was run, they resolved to create something similar.

The similarities are immediately apparent - a large polyglot developer conference, run by volunteers, taking place at an indoor waterpark. They even chose another location (Wisconsin Dells, WI) of the Kalahari water park. They added a bacon bar - an idea that I first saw implemented at CodeMash earlier this year and upped the ante by roasting a pig for dinner one night.

But it's not enough just to draw inspiration from success, have a good concept, and borrow a few ideas. To be successful, you still need to execute well. And the organizers of That Conference executed their plan very well.

They attracted an impressive list of speakers covering a wide variety of topics. Not only did this make the presentations great, but it also made the lunchtime and hallway conversations great. I saw some excellent presentations by Steve Bodnar, Jimmy Bogard, and Scott Hanselman, among others. My favourite was Bogard's session, which described how to write code that is easier to functional test.

My presentation on Azure Storage went really well. The audience was great. They asked good questions and were genuinely interested in this technology. I even overheard a couple people talking about my presentation in the lunch line. And thanks to Bob Laskey, I now have a new photo (below) that I can use on my conference profile pages. As you can see, I was very excited about my presentation.

Photo by Bob Laskey

But talking one-on-one with experts in the industry is where I get the most value from these conferences and I gained a lot of value from conversations at this conference (or is it “that conference”?). Many of the talks were so interesting, that I asked permission to record them, so you will soon see Chris Powers, Keith Casey, Ian Felton, Scott Hanselman, Samid Basu, Clark Sell, Jeff Nuckolls, Jay Harris, Michael Collier, and Ted Neward on Technology and Friends. Topics ranged from Windows Azure to telephony to home automation to the relationships between developers and managers.

That Conference included a few extra events, including a hackathon, a code retreat, a game night, open spaces, and a night in which the water park stayed open until 1AM, allowing the attendees a chance to play.

The only downside was the cost to attend, which was higher than most community events. The ticket cost was very reasonable ($350 for 3 days), but hotel rooms were almost $200 a night, the flight to Wisconsin was expensive, and the closest major airport is over an hour from Kalahari, meaning one still needed ground transportation. I was fortunate to receive sponsorship from Telerik (a sponsor of That Conference)and others received a training budget from their employers, but not everyone is so fortunate. Still, it is much cheaper than the large for-profit technical conferences.

600 attendees is an impressive turnout for a first-year conference. But the Kalahari can hold many more, so I expect this conference will grow next year. Especially if word gets out what a great job the organizers did.


That Conference home

Photos

Thursday, 23 August 2012 13:23:04 (GMT Daylight Time, UTC+01:00)
# Tuesday, 21 August 2012

Last week, Microsoft released Windows 8 and made it available to MSDN subscribers.

Recognizing that more applications will make this platform more successful, Microsoft is offering free help to developers who want to build applications for Windows 8.

You can sign up for the GenerationApp program to get guidance, including free access to Microsoft architects and consultants to advise you on everything from design to getting App Store approval. There are some limitations, so check out http://tinyurl.com/30daysWin8 for more information.

Tuesday, 21 August 2012 19:53:54 (GMT Daylight Time, UTC+01:00)
Tuesday, 21 August 2012 04:27:41 (GMT Daylight Time, UTC+01:00)
# Sunday, 19 August 2012

JavaScript’s popularity proves how useful people have found the language. Novices use it to add simple validations to web forms, while advanced build amazing applications with JavaScript.

Yet, for all its utility, many look at JavaScript with disdain and fear, pointing to dangerous features and to the difficult of dealing with the browser's Document Object Model.

In JavaScript: The Good Parts, Douglas Crockford distinguishes between the good features of JavaScript that make it and elegant and powerful language; and the bad parts that make it dangerous and difficult to understand. Crockford’s message is to use the good parts and avoid the bad parts and stop fearing JavaScript.

According to Crockford, most people misunderstand JavaScript and so they misuse it; then, they complain about the language.

Crockford acknowledges that the designers of JavaScript made some mistakes (global variables, for example), but that there are enough good features of the language to make it appealing to a wide range of users writing a wide range of applications. He notes that JavaScript succeeded as a platform for creating client code for the web – something that that the more powerful Java language attempted and failed badly – and that this proves JavaScript’s power.

Applications will be better and developers happier, notes Crockford, if developers avoid the bad parts of the language. For example, always use the "===" operator, which returns what most users expect because it doesn't do any type coercion. Avoid the confusion of the "==" operator, Crockford recommends.

Crockford's style is concise and straightforward. At fewer than 200 pages, the book has no room for distractions. Regular Expressions are presented and described and examples are shown how to use them. Crockford clearly describes Closures, a feature that is likely new to many developers; and he spells out how callbacks are implemented in JavaScript.

Before reading this book, I was unaware of implied semicolons in JavaScript and whey they can be dangerous. Crockford spelled out the dangers and how to avoid them very clearly.

JavaScript can be a great language if you confine your programs to using the best parts of the language and steer clear of most of the dangerous features. This book will help distinguish the two.

Sunday, 19 August 2012 03:36:23 (GMT Daylight Time, UTC+01:00)
# Tuesday, 14 August 2012

Here is Mike Wood's presentation on Continuum (of the Windows Azure Variety) at the July 2012 Great Lakes Area .NET User Group meeting.

Tuesday, 14 August 2012 13:36:59 (GMT Daylight Time, UTC+01:00)
# Monday, 13 August 2012
Monday, 13 August 2012 20:27:00 (GMT Daylight Time, UTC+01:00)