LINQ to SQL: Don't use a Static DataContext

By riceboyler on Apr 22 2009 | 0 Comments

I’ve had this weird bug happening with one of the first apps I wrote using LINQ to SQL, and today, I think I figured out why.  The error has been really random, but always involved in importing data into it.  In this case, they were trying to import Spot (TV Commercial) data into the database, and they kept getting my least favorite LINQ error of all time: “Row not found or changed.”  (Seriously, couldn’t we get something a LITTLE more expressive as an error?  But I digress…)

So today, I decided I would run a SQL Server Profile on it, and trace what was getting thrown at the database.  Glad I did, as I found out that at the end of it trying to insert 10 SPOT records into the database, it was trying to update a CALL (as in telephone call) record repeatedly.  WHY?

Then, I looked at the underlying code, and realized I was using a static DataContext from a Global class.  The problem appears to be that the update never completed, and so anytime I called the SubmitChanges() method on that static DataContext, it was still trying to update the database, and failing.

So, lesson learned?  Don’t use static DataContexts, as they’ll cause you lots of pain and consternation.

Post info

Tags:
Categories: Coding Adventures

The Passing of a Legend: Dan Miller

By riceboyler on Apr 13 2009 | 0 Comments

6a00d8341cbd4a53ef00e55008367c8834-150wi[1] Strangely, I have found myself really emotional distraught following the passing of Dan Miller, long-time anchor at WSMV (Channel 4) in Nashville.  I didn’t grow up in Nashville, but he still felt like a friend from the time I arrived here.

I’ve spent the last few hours poring over his blog (http://danmiller.typepad.com/) and coming to an even greater appreciation and recognition not for his talent as a broadcaster, but for his understanding of life and priorities. He posted about many varied topics, I’m sure whatever was on his mind that day, and reading his thoughts has helped me realize what his legacy is.  He was just a darn good man.  One of the things that many of his work associates have said about him is that he was just a down-to-earth guy who had no sense of “stardom” about him.  That is more than borne out in his blog.

I have also come to realize (with the passing of legendary Phillies announcer Harry Kalas) that I take the deaths of broadcasters somewhat personally.  It probably has something to do with my years in radio, and that yearning in the back of my heart to return to broadcasting in some way.  So, today I say good-bye to a friend that I never met.  While I feel for your family, I think the fact you were able to pass on while taking a walk with your good friend in your hometown demonstrates God’s mercy.

We’ll miss you Dan.

Post info

Tags:
Categories: