Shawn Wildermuth


My Rants and Raves about technology, programming, everything else...

Connections, Command and Transactions...oh my!

I was taking a refresher MCSD test today to get ready to take one of the tests and came upon a question that is wrong.  But it does infer that there is some confusion about how transactions are propogated to commands...or may be evidence that it is a bug.  For example:

SqlConnection conn = null;
SqlTransaction tx = null;
try
{
  // Create a new Connection
  conn = new SqlConnection("Server=.;Database=Northwind;Integrated Security=true;");

  // Open the Connection
  conn.Open();

  // Start a Transaction and create a new Command
  tx = conn.BeginTransaction();
  using (SqlCommand cmd = new SqlCommand())
  {
    // Set the Connection to the command
    cmd.Connection = conn;

    // NOTE: I do not explicitly set the TX to the Command
    //cmd.Transaction = tx;

    // Insert new values and execute it 
    // (within the transaction)
    cmd.CommandText = @"INSERT INTO Customers (CustomerID, CompanyName) 
                        VALUES ('ZZZZY', 'My New Company');";
    cmd.ExecuteNonQuery();

    // Insert new values, but the table name is wrong
    cmd.CommandText = @"INSERT INTO Companies (CompanyID) VALUES('ANother Company')";
    cmd.ExecuteNonQuery();

    // We should never get here since the query is wrong
    tx.Commit();
  }
}
catch (Exception ex)
{
  // Rollback the tx if error'd
  if (tx != null) tx.Rollback();
}
finally
{
  tx.Dispose();
  // Close the connection just in case
  if (conn != null)
  {
    conn.Close();
    conn.Dispose();
  }
}

This code fails because I do not explicitly set the transaction to the command.  Unfortuately, you must set the connection and the transaction.  This seems like a bug because you cannot execute a command on the connection (that has an pending transaction) without throwing an error. 

In Georgia At Last...

Url: http://atlanta.com

After a harrowing couple of weeks we're finally here.  We got into town on Friday, two trips to the airport, three cats, one fiance...check.  Much to my dismay, the apartment we had gotten was nothing like the model.  Frankly, it was a dump.  What to do?

Quoted in e-Week!

Url: http://www.eweek.com/article2/0,1759,1641492,00...

Today, I am quoted in e-Week about my opinion of what's happening to Longhorn...specifically about WinFS.  Hope I didn't offend anyone in Redmond ;)

I am going to miss Cairo...sorry...WinFS

Url: http://news.com.com/Microsoft+corrals+changes+f...

After spending hours digging through Longhorn builds to try and understand WinFS, I have to say that I am really bummed that it is getting pushed out.  I think I understand Redmond's approach here, but they've been promising something like WinFS for years now. 

UML/Database Modeler that I actually like!

Url: http://www.sparxsystems.com

While trolling the DevelopMentor .NET Lists, William D. Bartholomew mentioned a new UML tool that does round-tripping to and from code.  I've used Rational's (IBM's) XDE before to do this, but it is buggy and hates source code control. 

Doom 3....Lasting Impressions...

Url: http://www.doom3.com

After spending a couple evenings with my new friend, Mr. Doom 3, I have to highly recommend the game.  I am especially impressed by the scalability of the graphics engine.  Even on my mediocre system, I could get FSAA 2x and high level detail to work acceptably. 

Doom 3...A First Impression...

Url: http://www.doom3.com

I spent an hour with John Carmack's latest creation this evening.  The start of the game is surprisingly slow...it lets you walk around and really start to buy into the story.  By the time the monsters started to jump out at me, they had lulled me into a sense of security.  Impressively, the game runs well on my middle of the road system:

Decoupling Interfaces and Number of Assemblies

I have been having a conversation about coupling of objects at the interface level.  While I am not a fan of coupling objects together, I would like to be able to shortcut some factory code to make the interface be more intuitive.  For example, here is code that decouples the interface:

class Foo
{
  // ...
  Guid _barID;
  public Guid BarID
  {
    get { return _barID; }
  }
}

Foo foo = new Foo();
Bar bar = Bar.GetBar(foo.BarID);

Whereas I don't want to tie the objects together, but simply call the factory (the GetBar method) within the Foo class to make getting objects easier and more intuitive. For example:

Finding Tim Ewald's Blog

Url: http://www.pluralsite.com/blogs/tewald/default....

I lost all my NewsGator feeds so I was tracking down my favorite people...and of course Tim's one of them.  It was fun...Here's the trail I followed:

My First Day as a Magenic Consultant

Url: http://www.magenic.com

I just joined Magenic Technology as a Consultant and they put me at a client right away.  Its been so long since I commuted to a job that it was kinda wierd getting up at 6am and driving for an hour.  After a couple of years of getting up at the crack of noon and working till late into the night, this is a great change...of course after a couple weeks of this, I may not like it but we'll see.

The Daily WTF

Url: http://thedailywtf.com

Novell Shipping Mono Tools?

Url: http://news.com.com/Novell+ships+cross-platform...

No Yukon and VS.NET Betas at TechEd Europe?

Url: http://news.com.com/Microsoft+reaches+beyond+pr...

Evidently MS slipped on thier pledge to deliver the betas at the conference.  This article implies that they are claiming that the betas are “imminent“...wonder what that really means?  Q3?  Q4?

VS.NET and SQL Server "Express"?

Url: http://news.com.com/Microsoft+reaches+beyond+pr...

Looks like MS is going after the 'hobbyist' with their new “Express” line of development products.  Wonder if this will really stem the MySQL tide or not.  Perhaps the SQL Server Express edition will be a better solution than MSDE.

TechEd Europe!

How I wish I were there.  Evidently the Yukon Public Beta and the VS.NET 2005 Beta will be available.  Get them while they're hot!

For all attendees, skip the Heiniken Museum...you're gonna want to remember this convention!  TechEd will be very “lekker” this year. 

No COMDEX this year!

Url: http://news.com.com/Organizer+cancels+Comdex+20...

The Taligent Effect (via Don Box)

Url: http://www.gotdotnet.com/team/dbox/default.aspx...

I hate to blog about a blog, but everyone in software development should read this post from Don Box's blog.  Thanks to him I now have a name for this.  Too many times over the past five years have I been stuck in the middle of the “Academic” vs. “Pragmatic” discussion of some technology. 

Another Reason to Hate the Windows Indexing Service!

Url: http://support.microsoft.com/default.aspx?scid=...

I've been dealing with this nasty ASP.NET Configuration Error that only happens on my dev machine for several weeks now.  Inexplicably, it will think that some random DLL that is part of my project is locked while it is trying to do the aspx compilation.  I finally found the solution in the MS Support Database;  the solution?  Disable the Indexing Service (or exclude the ASP.NET temporary files section).  Arg!  The problem seems to be when my build copies a copy of a .dll to the temporary files section, it would start to be indexed by the Indexing Service and was locked so that the aspx compilation couldn't overwrite it.

Eagerly Awaiting Cassini's Arrival at Saturn

Url: http://www.space.com/astronotes/astronotes.html

MetaBuilders ASP.NET Controls

Url: http://www.metabuilders.com

I just wanted to give a shout out to Andy Smith of MetaBuilders ASP.NET controls.  I regularly use his DialogWindow and FirstFocus controls.  He has a number of controls on his site that are just great, but I can only speak for those two.  My $0.02 review of them are:

Steven Hawking and Lou Gehrig's Disease (ALS)

Guess I don't post for a month and then post everything I think of...

I was watching Jeopardy (as usual) and it mentioned that Steven Hawking was diagnosed with ALS (Lou Gehrig's Disease) in the 1960's.  I didn't think you could survive more than a couple years with ALS.  My step-father died in a scant two years after he was diagnosed.  Am I nuts?

After a Couple Weeks With the New Longhorn Build

I've had the WinHEC build of Longhorn for a while now and I have to say I am very pleasantly surprised.  It seems that Longhorn is really coming along.  I am very focused on WinFS programming, so I have not had too much time to dig into other interesting topics like Avalon (though Chris Sells loves the data binding) and Indigo.

The biggest change that has effected me is the lack of VS.NET.  Because of very different development schedules, there is not a version of VS.NET that works with this release of Longhorn.  At first I was a bit daunted...I have become so dependent on the tools.  I haven't compiled from the command-line in quite a while.  Luckily, MSBuild came to the rescue.  After having been using NAnt, I was unsure what the big deal with MSBuild was and why it mattered.  I am now a big fan.  Instead of having to learn their XML syntax, I was delighted to find out that it will build based on a csproj file.  This helped me out a lot, because I know how to write those files like the back of my hand (mostly from hacking csproj's to fix annoying problems like licx files remaining after you remove a reference). 

Al Qaeda Websites?

I was reading this article on MSNBC yesterday and they mentioned that an Al Qaeda website was showing a video and messages about the oil worker hostage in Saudi Arabia.  Though the site has been shut down by now, I was surprised it hadn't been shut down before.

Don't get me wrong, I am a big advocate of Free Speech.  In my opinion, ransoms and announcements of crimes is not protected speech.  It took me all of 90 seconds to do a WHOIS search to find the host and it is unclear to me whether the site was hosted as a freebie site, someone paid the host (hostanime.com) for the site, or someone hacked the host to put up the site. 

All Quiet on the Wildermuth Front

What a strange trip it's been...


Application Name WilderBlog Environment Name Production
Application Ver 1.1.0.0 Runtime Framework .NETCoreApp,Version=v1.1
App Path D:\home\site\wwwroot Runtime Version .NET Core 4.6.25211.01
Operating System Microsoft Windows 6.2.9200 Runtime Arch X86