Windows Forms DataBinding

Here is a great article on binding in Windows Forms - specifically against a dataset. Lot's of gotcha's covered.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/databinding_winforms10_11.asp

SQLDependancy Caching

One of the new features in version 2.0 of ASP.NET is a new form of cCaching. This is a cool feature but not as easy to get working as it would seem.

In case you haven't heard about it, using SQL Dependency you can tell the Web Page not to refresh until the DB notifies it that the data has changed.

There are three steps you have to do to get this feature to work.

1. Add this section to your Web.Config file:

<connectionStrings>

<add name="pubs" connectionString="Integrated Security=SSPI;User ID=sa;Password=sa;Data Source=LONDON;Initial Catalog=pubs;Persist Security Info=False;Workstation ID=DLLOYD" />

connectionStrings>

<system.web>

<caching>

<sqlCacheDependency enabled="true" pollTime="500">

<databases>

<add name="pubs" connectionStringName="pubs" />

databases>

sqlCacheDependency>

caching>

system.web>

Watch out because there are articles out there that say the tag should be CACHE not CACHING

2. You have to run an administrative utility (aspnet_regsqlcache) that enables a Database and Table for SQL cache dependency.

aspnet_regsqlcache -S (local) -U "sa" -P "sa" -d pubs -t authors -ed (Enable the DataBase)

aspnet_regsqlcache -S (local) -U "sa" -P "sa" -d pubs -t authors -et (Enable the Table)

aspnet_regsqlcache /? (Too see all the commandline switches)

3. On the page itself, in the Page Directive add the following line.

<%@ OutPutCache Duration=6000 SQLDependency=“pubs:authors“ VaryByParams=“*“%>

Talking Without an Audience

I had the unexpected opportunity earlier today to do my first MSDN DevChat webcast.  Or a webcast of any kind. One of my colleagues, Dave Lloyd was giving a webcast on the new features in ASP.NET Whidbey.  The webcasts originated from the Microsoft Canada office and I went along to be his question monkey and to provide an audience. Once I got to Microsoft, Adam Gallant offered me the chance to do a webcast on C# scheduled for two hours later. Never being one to turn down a chance to speak, regardless of the circumstances, I accepted.

For those of you who have never done a webcast, the process is straightforward.  We were in a small conference room, four of us in total. The presenter (Dave) is hooked up to the LiveMeeting manager and a headset.  Dave basically controls the slides and demos and speaks into the headset.  The rest of use handle any questions or issues as they arise.

The weird part of the process is something that presenters will understand.  I personally thrive on the interaction that I get from speaking in front of an audience.  More importantly, I tend to adjust what I say and how I say it based on the feedback that I get.  If I see a glazed look, I dial back on the details.  If I hear snoring, I rachet up the 'coolness' factor. You get the picture.

The challenge of a webcast is that none of this feedback is available.  You're in a room talking on the telephone without the benefit of seeing or hearing the audience.  It is a surprisingly isolated experience.  To make it even worse, the other people in the room have their own conversations going on (quietly, of course) as they answer questions and deal with problems. I just ended up closing my eyes and kept going forward.

So the next time that you're listening to a webcast, feel free to chime in with any questions or feedback your have.  It will probably be welcomed by the speaker, if only to let them know that there really are people on the other side of the network connection.

Microsoft Business Framework goes into Longhorn/Orcas

MBF is being delayed until Longhorn. Up until reading this, it was my understanding that MBF was planned for a post Whidbey release along with ObjectSpaces. MBF is a pretty big thing scope-wise. I think it is the right thing to do to wait until Longhorn. I just hope ObjectSpaces doesn't fall into that same planning.

MCT Day at TechEd

TechEd is coming up. Scary thing is my schedule is about 75% booked - and not with actual sessions. I'll talk more about the stuff I'm involved with over the coming weeks and during TechEd.

The interesting thing I got today was the Agenda for “MCT Day” - which is the Saturday before the conference for MS Certified Trainers. There are lots of interesting things on the agenda, but the person I'm most looking forward to speaking is Richard Klees.

Richard does the training for a lot of MS presenters and is very well recognized as the speaker of speakers, the trainer of trainers.. He's doing some time with each TechEd speaker again this year. Just hearing him talk for an hour is going to be a lot of fun.

 

VS Live Party

We threw a party on Thursday night after VS Live Toronto to help blow off some steam. VS Live in Toronto was a good time. A few people agree.

  • Jay Roxe was one of the speakers and joined us for a night on the town.
  • Datagrid Girl Marcie Robillard too. Turns out we share some PowerBuilder history from back at her days with Anderson Consulting. Marcie was also one of the speakers. I watched her presentation to see if I could pick up any public speaking tips, but I left learning some technical things. A) You can do a DataSet.ReadXml and pass it an url, not just a filename. B) The file/url you point it at can be any reasonably formed xml document - not just a previously saved dataset. She loaded the RSS feed from the Code Project. Cool. In practice, an untyped DS does lots of inferring which can be problematic so stay tuned for a fully fleshed out tip on doing some typed DS loading of XML docs.
  • Mike Flasko has posted some pictures from VS Live. Mike is on the Imagine Cup Canadian winning team. Be sure to check out the sub folder from our party. Elisa Johnson and Jason Kemp also from the team were there. A very nice group of people I was glad to meet.
  • Thanks to Billy Hollis, Keith Pleas, Paul Yucknovic??, Rob Windsor, David Totzke, Chris Kinsman and of course the rest of the ObjectSharp clan for coming out on the town.

 

MSDN DevChat - ASP.NET Whidbey - May 11, 2004 - Toronto - -19

On May 14th at 1:00 pm EDT, Dave Lloyd, one of our senior consultants is giving a webcast on the upcoming version of ASP.NET, codenamed Whidbey. To get more information or to register for the webcast, click here

Uninstalling Whidbey PDC Preview

For anyone else who received the recent Whidbey 2005 preview. And thought they would uninstall an older version of Whidbey. Here is what happened when I did it.

  1. I un-installed Whidbey.
  2. Then I had to separately un-install:
    • Microsoft .NET Framework 1.2
    • Microsoft Visual J# redistributable Package 1.1
  3. Then to get Visual Studio 2003 working properly again, I had to reinstall:
    1. Visual Source Safe
    2. MSDN Library

And everything seems OK so far.

Building Maintainable Applications with Logging and Instrumentation - May 10, 2004 - Toronto - -20

Barry Gervin participated in an MSDN webcast last week talking about logging and instrumentation. Below is a summary of his presentation, and to the right you will find the accompanying slides and materials. You can also view the livemeeting recording here.

In this session we'll cover the world of logging and instrumenting your application. We'll discuss the various .NET framework components as well as higher level services as provided by the Exception Management Application Block, the Enterprise Instrumentation Framework and the Logging BLock. We'll discuss the various issues with persisting information in file logs, the event log, and WMI Performance Counters. We will also compare other alternative technologies such as log4net. We'll also discuss best practices for loging and instrumenting your application and provide some considerations for when and where it makes good sense to instrument your application from experiences in the field.

RSS Feeds and DataSets

So as I write this at 1:10 in the morning, I have just finished beating my head against a fairly hard wall.  The task was to load an RSS Feed into a DataSet.  Then once in the DataSet, the feed could be bound to a Datagrid, a DataRepeater, etc.  The plan was simple.  The strategy sound. Or so I thought.

"No plan survives contact with the enemy." -Field Marshal Helmuth von Moltke.

While I suspect that many of you are aware of the quote, it´s place in the process of strategic is frequently forgotten.  The quote is intended to remind strategists to set broad objectives and seize unexpected opportunities when they arise. Of course, in this instance, I´m using the more pessimistic “stuff happens“ meaning that is more commonly ascribed to the quote.

So I naively start the process by creating a DataSet object and using the ReadXml method to build it.  Due to the foresight of the .NET Framework designers, I can simply pass the URL to the RSS Feed as a parameter.  Sweet.

But then I run into a snag. Or, to put it another way, Moltke proved his prescience. Within ReadXml, a DuplicateNameException is thrown. The specific message was  “A column named 'comments' already belongs to this DataTable.“ After an examination of the RSS feed, I discovered that the Slash RSS module uses a Comments tag. In the RSS feed, it is properly namespaced, but the namespace is not recognized by ReadXml.  So the Comments tag in RSS clashes with the Comments tag in Slash RSS.

The solution to this problem is not as clean as I would have liked.  In my ideal world, there would be a way to limit the namespaces that are loaded into the DataSet.  Perhaps using the XmlNamespaceManager, for instance.  But for all the Googling that I did, there doesn't appear to be any solution down this alley. So instead I turned to a kludgey (from my perspective) method that involves transforming the RSS feed using XSL.

My next problem immediately followed this solution.  When I processed the transformed RSS feed, another exception was thrown.  This time it was a ArgumentException that read "The same table (p) cannot be the child table in two nested relations.". Back to the RSS feed we went.  What we saw was that if the post was XHTML compliant, then a separate <Body> block was contained within the post.  In this <Body> block was the post complete with the various markup tags (like <p>) intact.  This differs from the normal format of the post, where the angle brackets surrounding the tag are converted the &lt; and &gt;. The result was that ReadXml was choking on the fact that <P> existed in to separate items.

Back to the XSL, where I excluded the <Body> block from the RSS feed.  Now my XSL file looks like the following:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"   
     xmlns
:slash="http://purl.org/rss/1.0/modules/slash/" 
     xmlns
:xhtml="http://www.w3.org/1999/xhtml" >

    <xsl:template match="*|@*|comment()|text()">
       
<xsl:copy>
           
<xsl:apply-templates select="*|@*|comment()|text()"/>
       
</xsl:copy>
    </
xsl:template>

    <xsl:template match="slash:comments">
        <SlashComments>
            <
xsl:apply-templates select="*|@*|comment()|text()"/>
        </
SlashComments>
    </
xsl:template>

    <xsl:template match="xhtml:body"></xsl:template>

</xsl:stylesheet>

Mission accomplished.  I now have a DataSet that contains the necessary information from an RSS Feed.  Next up is to actually bind it to the desired control.  Haven't gotten around to it yet, but I'm hoping that it is much easier.  It certainly shouldn't be much more challenging.