Tag Archives: C#

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 of that mapping for any DataTable you send it.

Continue reading SqlBulkCopy Matching Columns

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 lists.

My attempts to smooth that out have resulted in a lot of UI revisions as I tried to find good ways for displaying and updating all this info without slowing down the UI to uselessness (buh-bye, Table Layout Panel). Here’s what I’m sitting with now:

It’s not pretty, and there are more tweaks in the queue (like just putting the DCs/per days right with each class, probably), although for the moment it works well enough (read: stuff doesn’t end up hidden and inaccessible) that I can get functionality working again.

Like that 0 modifier for a Wisdom of 15. >_>

Continue reading The Contortions of a Spell List

Minor bug fix release of d20 Spell Lists – v0.1.4293

Downloadable from The Charon Sheet. (Also, I’m currently reading The Principles of Beautiful Web Design so’s I can make TCS less sucky and more purdy. Expect design changes there as I learn how to do this crap from scratch.)

Only two issues fixed, but they were kinda show-stoppers for the affected folks. Details on the issues fixed.

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 a large list of available spells, I needed a quick way to see all of my available options without flipping through two sourcebooks and my swap list at the table. Then I wanted to avoid having the jotted down short-hand description of the spell that I refresh every “day” as I try out new spells.

Pain in the ass.

A bit of Googling lead me to conclude that with the advent of D&D 4e, many of the 3.5e resources… disappeared. And by disappeared, I mean:

All files withdrawn at the request of Wizards of the Coast.

Continue reading d20 3.5 SRD Spell Lists: First Beta

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 1currentURL != Request.RawUrl) && (!currentURL.Contains(".axd")
    {
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", currentURL);
    }
}

Continue reading Lower-casing URIs in .NET

Footnotes   [ + ]

1. currentURL != Request.RawUrl) && (!currentURL.Contains(".axd"