Friday, July 31, 2015


One stackoverflow poster with 46 upvotes stated this is the relationship:

iterative and incremental methodologies, include
--agile methodologies, include

Wednesday, July 22, 2015

Nullable Types and Casting

Situation: You have non-string types  in the database that can be null. You are simply trying to populate a view, so you are assigning the model properties.  (this is one of the most elementary processes in all web programming)

Remember, we are dealing with a NULLABLE TYPE in our model:
public class myModel{
 public int? myProperty  {get;set;}

For my example, I'm using int types, but applies to double,  DateTime, etc.

If you do the most intuitive:
myModel.myProperty = dr["myProperty"]
you will be told you "cannot implicity convert type object to int" ... "are you missing a cast?"

So you try a cast:

myModel.myProperty = (int?) dr["myProperty"]

But even though you had been smart enough to use the nullable indicator in your explicit cast (the question mark, ?), you will still get "InvalidCastException".

At this point you might be smart enough to attempt this with TryParse along with the Ternary Operator (otherwise you have to use multiple lines of code, though you still have to use at least two since you need to create the out variable, as the out variable is not allowed to be a property):

int tmpInt;
myModel.myProperty = Int.TryParse(dr["myProperty"].ToString(),out tmpInt) ? tmpInt : null

But !surprise!, you won't be allowed to build this.  The compiler doesn't seem to understand that we are dealing with a nullable type.

At this point you might just resort to using TryCatch:
   myModel.myProperty = Convert.ToInt(dr["myProperty"].ToString());
  myModel.myProperty = null;

But it turns out, if you knew this trick, you could get the TryParse n' Ternary option to work:

int tmpInt;
myModel.myProperty = Int.TryParse(dr["myProperty"].ToString(),out tmpInt) ? tmpInt : (int?)null

Can you spot the difference? :)

Wednesday, July 8, 2015

talkin' fancy

Do you feel more comfortable with A or B?

A. "You can implement it in one of two ways, declaratively or programmatically."
B. "You can do it in one of two ways, in your config file or your code."

Tuesday, July 7, 2015

Lazy-Ass, Get-It Done C# Download Stuff Off Internet

When you just need a li'l automation, you can use this to iterate through known names, etc.

WebClient client = new WebClient();
string fileUrlTemp= "";
client.DownloadFile(fileUrlTemp, "img.jpg");

Monday, July 6, 2015

Facebook for your Website: What you need to know

When a Facebook user links to your site, FB generates a preview that might not always be what you want users to see.

Here is how to control it.

IMPORTANT! Once anybody has linked to your site, FB will store a cache, and you'll have to wait 24-hours before FB will listen to any meta-tags you update the page with.

(a quick hack around this is to just create a new page, like "index2.html", or "indexFacebook.html", to use for sharing)

Put this in your page:

<html xmlns=""
<title>Vaudeville Book</title>
<meta property="og:image" content="" />
<meta property="og:url" content=""/>
<meta property="og:title" content="How to Enter Vaudeville"/>
<meta property="og:site_name" content="How to Enter Vaudeville: The Website"/>
<meta property="og:description" content="The new economy is here, and the non-monied classes must learn how to amuse and entertain the monied classes."/>

Probably most significant is the og:image value, because that is the picture that will be used for the the "preview" in the Facebook status post.

Then, to check out how it works, go to:

and enter in the url to your page.

Incidentally, this is all called "Open Graph", and here is a link to the page with info about it:
and trusty Wikipedia:

border-collapse: collapse

table {
    border-collapse: collapse;

Would create trouble in IE8 and before.
While IE 8 was in the wild (mid-2009 - ?)... would not have been used ....
IE 8 was default browser for Win 7....

Even in October 2014, IE 8 was almost 20% of web traffic.

Sunday, July 5, 2015

How to copy a table, with its data, in SQL Server (no, Mgt Studio doesn't do it for you)

You would really think that this would be a built-in feature available from the context menu.  But as proof it most definitely is NOT, see:

As Microsoft tells you, just do this:

SELECT * INTO BizDev.CurrCustomers FROM Sales.Customers

Thursday, July 2, 2015

Exception Handling not working on Server

This is important stuff. Nothing sucks worse than when Exception Handling actually breaks your application.  And nothing sucks worse than when something behaves one way locally and a different way once it gets deployed to your server.

As this article explains, you can have a global error handler in your Global.asax file that gets fired on your local machine, but if your web.config file is lacking a CustomErrors setting, it won't work on an IIS server.

So be sure your web.config has this section:

<customErrors mode="On|Off|RemoteOnly" />

and for starters, set it to:

<customErrors mode="Off" />