Random Notes

Here are things that I typically forget and need to keep as notes. (I stole this idea from Gabe.)

Comments

.Net tableadapter's conecttion string

In the XSD designer, click on the tableadapter (bottom half) and in the properties window, expand Connection. Change Modifier from the default "Assembly" to "Public" and the tableadapter will now have a public member "Connection" that you can change the connection string on before calling any methods that return a dataset.

Yes, I didn't know about this either and have done the same thing you describe above before finding this out =p

TableAdapters

Hmm. I sort of wish I'd known that when I first started working with TableAdapters. Although, really, having to set the connection string every time is a little more complicated than modifying a setting. (Well, at least modifying a setting in the config file. Not so much if you're doing it programmatically.)

Incidentally, I read a bit today on DLinq which is coming out in Visual Studio Orcas. There's a couple of little things about TableAdapters that bug me (the connection string thing being one of them) and it's starting to look like DLinq clears up a lot of them.

TableAdapters...

Oh, I thought you were looking for a way to dynamically change the connection. By default in the DataSet Designer Wizard tableadapters use the ConnectionStrings section of App/Web.config

I like wizards.

TableAdapters

Kinda. Here's the way it works: I've got a DLL that contains my object model. I'm using it in a web application (of which there are local dev, beta, and soon to be a live version), in a scheduled task that sends out notifications, and in an NUnit unit test module. I need these versions to use different databases. For the websites and the unit tests, I can use the web.config/app.config method. For the scheduled task version, I want to be able to set it programmatically based on command line options.

That's the plan, anyway. Although it may reflect more the way I would do it in Python than the way it should be done in .NET.