• On Life and Love

    SqlBulkCopy Matching Columns

    If you’re trying to do a SqlBulkCopy using a DataTable and getting lots of column type (integer, string) mismatches, it’s probably because you haven’t mapped not only the column types, but also the column names. SqlBulkCopy assumes that your DataTable is going to have its columns in the same order as the database table, which will cause mismatches when it tries to send your (string) Name field into your (int) Age column. Just having your DataTable column names match the table isn’t enough, either. There must be a manual mapping. But if your DataTable column names are the same as the table column names, a simple method can take care…

  • On Life and Love

    The Contortions of a Spell List

    So I’ve been working on the next major release of the D20 Spell Lists app, and have found myself in a code and UI reorganization/refactoring jungle as I’ve refined my feature set and how I want to handle things. One of the common-enough cases that the current version doesn’t handle well that I think needs to be is multiple spellcaster classes. If I’m a Druid 5/Bard 6, I’m going to want to keep separate spell lists, and will have different DCs, spells known, and spells per day to contend with. With the current version, the best solution is probably to have two different character files, each with its own spell…

  • On Life and Love

    d20 3.5 SRD Spell Lists: First Beta

    So I’m in a D&D 3.5 campaign now. And I’m playing a Druid, which is kinda exciting–it’s the first time I’ve played a Druid at a high enough level that I can shapeshift, and I just tipped 5th level on Sunday. (Campaigns always fizzle out early…) Anyway, the campaign is a hodgepodge of standard D&D and Sandstorm, and summoning restrictions by the GM mean that my spell list involves a fair bit of swapping out that’s a little annoying to manage. For instance, I’m using Sandstorm’s “Desiccate” instead of “Summon Nature’s Ally II”, since I can’t summon. Since Druids are the type to prepare a few spells per day from…

  • Uncategorized

    Lower-casing URIs in .NET

    A few months ago, a client asked that their .NET site have all its URIs lower-cased for search-engine optimization purposes. This was an existing site with a lot of files, already in SVN. SVN in Windows is wonky (by which I mean, terribly broken) when it comes to changing the case of filenames, so I decided to go for a programmatic solution to the renaming. I ended up with the following: void Application_BeginRequest(object sender, EventArgs e) {     string currentURL = Request.RawUrl.ToLower();     if ((currentURL != Request.RawUrl) && (!currentURL.Contains(".axd")))     {         Response.Status = "301 Moved Permanently";         Response.AddHeader("Location", currentURL);     } } The most important thing is the “!currentURL.Contains(“.axd”)” condition. .NET sticks its scripts in…