Archives / 2004 / March
  • Nested Repeaters

    Scott just posted a great article - Nested Repeaters Part 1. Great code samples and explanations of a topic that can be a bit confusing. I like the databinding syntax he's using, too:

    You might have noticed that I use a databinding syntax which is a bit different to that used in most documentation, the DataBinder.Eval syntax - e.g., <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %> , instead I tend to use this syntax <%# string.Format("{0:c}",((DataRowView)Container.DataItem)["Price"])%> - I've covered my reasons for this in the past and well, I just prefer it...

    The DataBinder.Eval syntax has always kind of bugged me, too, and Scott's previous post about this is pretty persuasive.


  • [SQL] - Random Dates / Data for testing

    NewID() is a really useful SQL function, since it's resolved on a per row rather than per query basis. That comes in handy if you want random values for each row in a table.

    For example, this (ad-hoc) query will update your [datefield] with a random date within the past five days:

    update [tablename] 
    set [datefield] =
    cast(getdate() as int)
    -5*rand(cast(cast(newid() as binary(8)) as int))
    as datetime)
    There's another (more well known) trick for getting results back in random order that I might as well mention while I'm at it:
    select * from [tablename] order by newid()


  • Salamander .NET Decompiler - Web Based Demo

    Reflector is cool (really, really cool), but only decompiles a method at a time. Remotesoft has a cool online demo of their Salamander .NET Decompiler that can decompile an entire assembly at a time. It's web based, so you don't even have to download or install anything - just upload your dll and browse / download your source.

    Caveat: Online version only decompiles 10 methods per class. The full version look great but costs $995ish. Do not taunt Happy Fun Ball.


  • Fun way to get yourself in trouble with overloading

    Debugged an interesting thing the other day. Turned out to be caused by an improper use of overloading.

    Chapter 1.

    Developer A writes a function with two overloads:

    string GetGreeting(string FirstName, string LastName)
      return string.Format("Hello, {0} {1}! Nice to have you back!",FirstName,LastName);

    public string GetGreeting(string UserName, string Password, string Error)
      return "Hello, user! Please update your profile so we can greet you by name.";

    All good so far...

    Chapter 2.

    We've merged with another company. The "Merge Databases" project won't be done until next fiscal year, so we're just using company codes to indicate which company you're affiliated with. Developer B adds a company code to both overloads to add some extra functionality based on the Company Code:

    public string GetGreeting(string FirstName, string LastName, string CompanyCode)
      if (CompanyCode == "AAA")
        return string.Format("Hello, {0} {1}! I can't believe we got bought out!");
        return string.Format("Bonjour, {0} {1}!");

    public string GetGreeting(string UserName,string Password,string Error,string CompanyCode)
      if (CompanyCode == "AAA")
        return "Hello, user! Please update your profile so we can greet you by name.";
        return "Bonjour, utilisateur!  Veuillez mettre à jour votre profil ainsi nous pouvons vous saluer de nom. Or whatever.";

    Chapter 3.

    Developer C (who will be played by Jon) has to troubleshoot why passwords are being shown in welcome messages. Several releases later. Why? Some (actually, all) old code calling
    has been redirected to
    because the signatures are the same.

    This is a fun one because it'll compile just fine, and you won't know who's calling what without searching the whole project.

    (1) Developer C made up an example that will probably not compile (
    No Intellisense Day) and will likely be of no business value. Trust me, the pain was real.
    (2) Developer C is sure there's some cool CS term for the above affect (something like Polymorphic Andorgeny or Sociopathic Signature Usurpation) that might be nice to know but wouldn't have succeeded in robbing Developer C of the fun of debugging this issue.


  • VS 2003 Macros gone screwy

    My VS Macros aren't working - just flicker briefly, the little macro icon shows in the notfication tray, and the macro doesn't actually execute. Debugger doesn't break on breakpoints in the VS Macro IDE.

    I've got 2002 and 2003 side by side; it's not working for either. It used to work for VS 2002; I recently installed VS 2003 and don't know for sure if it ever worked there.

    I've done my Google Groups Due Diligence.

    Any hints?



  • [tip] string.Split(',')

    Why bother with

    myString.Split(new Char[] {','})
    when you can type

    I felt dumb for having missed this, but all the sample code I've seen since then (including on MSDN) always uses the new Char[] {','} syntax.

    Thanks, Scott, for correcting my previous post complaining about this syntax.


  • Confluence 64

    Old computer locking up + 64 bit loaded Athlon under $900 + Free (for a year) Windows Server 2003 64 bit = chance try to use the word confluence in an equation. Fortuitous.

    Since this is also a family computer, I'm not gutsy enough to put WinXP-64 or Win2003-64 on the primary partition, although I played with them for a bit. I'll prolly try a dual boot setup later. The WinXP-64 AMD info was vague enough that I had fears of the one year time bomb hitting me with a hefty bill for the permanent install. Also, there's no theme support. Gotta have a green start button.

    Anyone dual booting with WinXP-32 and Win2003-64?


  • Free Whidbey!

    While it's frightening to go out on a limb with a fringe statement like this (heck, even Frans goes party line on this one!), I'm willing to stand up and be counted in the Free Whidbey movement (logo to follow).

    While it's difficult to find the courage to agree with everyone who thinks of Whidbey as a software project rather than an island, I fall back to simple statistics. SQL Server is an 8.0 release, so a new version number will only give us a 12.5% upgrade. Moving from VS.NET 1.1 to 2.0 will give us a whopping 81% upgrade!

    Joking aside, SQL Server is a mature product. The new features will be nice, but I don't have to jump through hoops to get my work done with it as is. Whidbey, on the other hand, will make a huge difference in how I do my work.