Archives / 2004 / April
  • Interesting SQL Dilemma -- Need Help

    Lets say I have a table with only a single field in it, which happens to be an identity field:

    CREATE TABLE TestIds (
      TestId int IDENTITY (1, 1) NOT NULL

    How do I insert a new record into this table -- all of these I've tried so far have failed:

    • INSERT INTO TestIds () VALUES ()
    • INSERT INTO TestIds (TestId) VALUES ()
    • INSERT INTO TestIds (TestId) VALUES (@@Identity)
    • INSERT INTO TestIds (TestId) VALUES (1)
    • INSERT INTO TestIds (TestId) VALUES (NULL)
    • INSERT INTO TestIds

    Update: I now have a solution for MS SQL, but I still need one for Access too.



  • Convert.ChangeType does not support Guids

    I suppose one can argue that this is not a “bug”, but it sure feels like one to me
    -- the following Convert.ChangeType, with a Guid type, throws an exception:

    Convert.ChangeType(”12345678-1234-1234-1234-1234567890AB”, typeof(Guid))

    Note that this is easy enough to resolve, since you can use new Guid() instead,
    but this isn't what you are expecting to do when converting types that are dynamic.


  • House For Sale in Woodstock (Georgia)

    Anyone want to buy a nice 6-1/2 year old 3-bedroom 2-1/2 bath house with a huge front porch and a drive-under basement with 2 finished bonus rooms in a good size culdesac lot in Woodstock (Georgia) ?  I realize the answer on a technical blog that goes around the world is probably no -- but its worth a shot -- you never know.  They finally released one of the lots that we've been eyeing to build a bigger house, with a dedicated home office for my new independent life, so we'll be getting our current house on the market very soon.


  • Thanks to Contributors of WilsonORMapper v2.1

    I want to give a very special thanks to several of my subscribers for their contributions to the just released WilsonORMapper Version 2.1:

    1) David D'Amico and Craig Tucker improved the ORHelper to automatically handle 1-to-many and many-to-1 relations, as well as adding default null-values.  These changes to the ORHelper, which I don't usually try to improve since its just a help tool, are definitely going to be a significant assistance.

    2) Jerry Shea add support for composite (multiple column) keys, enumerated member types, and an improvement to the ObjectHolder's InnerObject.  The composite key capability may not apply to many users, but its huge for those that were needing this support.

    3) Ken Muse added the GetObjectCount method, for getting record counts.

    Thanks to everyone, Paul Wilson


  • Going Independent Finally

    I'm saying goodbye to permanent employment and hello to Wilson Software Consulting. That's right, I've given my 2 weeks notice and started incorporating as an S-Corp. Risky?  Not at the moment, since I've already found an exclusive full-time client. Actually, they found me through my site and the other online activities that I do! They've got a lot to do, so I'm not looking for more clients, at least no time soon, although its nice to get my own corp setup, since you never really know the future. Did I also say I'll be working from home?  That was definitely the clencher for me, as that saves me from at least 1 1/2 hours of Atlanta traffic everyday, if not more. And I really look forward to having a little more flexibility with my family time, and just in time for summer -- oops, my allergies will keep me indoors regardless.


  • MasterPages in .NET v1.* -- Dynamic Masters

    It seems that lately my implementation of MasterPages for .NET v1.* is getting a lot of hits again, which is kind of funny considering its been out for over a year.  Anyhow, one of the questions that I get asked a lot is how to dynamically change the master template at runtime, which is obviously possible since I do it on my own site.  The solution to this problem all comes down to timing -- the Init event is already too late, so you need something earlier, like the AddParsedSubObject override.  Just be aware that this method is called for every root object added to the page, so make sure that you wrap any code you add to this method so that it only gets ran once.  So here's the code:

    protected override void AddParsedSubObject(object obj) {
      if (obj is MasterPage) {
        ((MasterPage) obj).TemplateFile = "~/Template.ascx";

    Note that while you can add this code to each page, MasterPages doesn't preclude you from using a base page class -- I put this code in my base page class on my site.  Also note that you can use any of the Request collections (Form, QueryString, Cookies), or Session, as the basis of your choice for the TemplateFile to make it truly dynamic.  Finally, if you are already playing with .NET v2.0, then see my Whidbey article for a version of this code that uses the TestDeviceFilter override, although this may change as Whidbey matures.  Note that my Whidbey article also has a fully functioning version of everything in the article for the .NET v1.* scenario in the download -- so its not just about Whidbey.


  • Matrix Spoof featuring Gates and Ballmer

    The MVP Summit featured a cool spoof of the Matrix featuring Bill Gates as Morpheus and Steve Ballmer as Neo.  Everyone wanted a copy of it, but we were told they didn't have the rights to give it to us.  Apparently it was also featured at Comdex last year, and here's a lot of pictures from it and half of the video.


  • Visual Source Safe, MVP Summit, and NDA Info

    So I got to ask at the MVP Summit today when MS was going to actually ship a workable source control system.  Now they make a big deal about how we are under NDA, but I'm going to tell you anyhow.  The answer was . . . (drum-roll) . . . they're know it sucks and they're working on it.  Hmmm -- I've heard that answer many times in very public settings -- so why have an NDA Q&A if the answers aren't anything new?


  • ObjectSpaces to be Separate Package ?

    Update: This is not a rumor -- it has been confirmed.

    Alex Thissen reports that the rumor is ObjectSpaces will be delivered as a separate package, instead of integrated into .NET v2.0 as it currently is in the previews.  I personally think this would be the right thing to do, since Microsoft has went out of its way to make it a MS SQL only product that no one else can plug into.  The downside of this will be that far fewer developers will end up seeing an O/R Mapper, since its hard to get people to install and play with something extra that they don't already understand and want.  I think its sad that its came to this, but I do think its the right thing -- the rest of the .NET teams seem to understand that they can get away with adding MS SQL optimized libraries, but they must also provide interfaces that Oracle and others can also plug into.  Of course, the upside of this, if its true, is that my ObjectSpaces “lite“ WilsonORMapper, as well as Frans' LLBLGen Pro and Thomas' EntityBroker, will get an extra lease on life.  :)  By the way Frans, what exactly does LLBL stand for?  And Thomas, why haven't you registered or  Sorry, I couldn't resist.


  • Attending the MVP Summit Next Week

    I'll be at the MVP Summit next week also.  I'm arriving late on Sunday at 6:26pm, so I may not see many of you Sunday night, although I'll try to make it if possible.  I'm staying at the W though, and Kirk's already told me the bar at the W is a good hangout, so maybe I'll see you there if nothing else.