The given columnMapping does not match up with any column in the source or destination

The SqlBulkCopy object is good, but probably super twitchy. The fact that it is case sensitive to columnames to me is a sign of likely low code quality, and the error that gives this blog entry its title is another.

Sometimes bulk copy will import a table from text without explicitly setting the columns. Sometimes you have to explicitly set the columns and poof! it works. It may have to do with white space or case sensitivity in the columns, or it may have to do with drivers making inaccurate counts of fields.

SqlBulkCopy bcp = new SqlBulkCopy(
“Server=.;persist security info=True;initial catalog=target;Integrated Security=SSPI”,
SqlBulkCopyOptions.KeepIdentity & SqlBulkCopyOptions.KeepNulls);

bcp.BatchSize = 50000;

for (int i=0;i {
string name = reader.GetName(i).Trim().ToLower();

for (int i = 0; i < bcp.ColumnMappings.Count-1; i++)
bcp.DestinationTableName = file.Name.Split(‘.’)[0];



NOTE: Even explicitly listing the columns often is not enough. I eventually gave up and used alternate techniques. The command is poorly documented with respect to what text formats are acceptable for BIT, DATETIME, IMAGE when doing heterogeneous bulkcopy. Until MSDN documents it, this otherwise fantastic tool is only reliable for copying from SQL to SQL with identical schemas and probably identical version and patch levels.

Cannot get IIS pickup directory.

In test and development, sometimes you don’t want to send the mail, you just want to write it to disk for reading as an .eml file.

IIS’s SMTP writes email to C:\Inetpub\mailroot\Pickup

To let ASP.NET use that, first, you can’t do it in medium trust. You can only send email over port 25 in medium trust, not to the drop folder.

YOu will also need this link:

Editing the metabase may be required.

Developers think other developers are retarded

These commenting patters are so common, it can only mean one thing, us developers think other developers are clinically brain dead.

Because we can’t read pascal or camel case, all method names have space expansion for comments. Which would be okay if that wasn’t the only comment.

//get value
public void getValue(){

Because we can’t read call signatures, why not repeat it?

//a public method returning no value taking one integer argument
public void setValue(int x){

Because you are too stupid to get it if you don’t read it twice

public int getValue(){

And we figure you probably don’t know English either, because words like “get” and “value” are pretty obscure and technical.
//retrieve a number
public int getValue(){

Because we don’t give a flying f*ck about comments, might as well make them all the same

//sets the value
public void getValue(){
//sets the value
public void setValue(){

Or empty but pretty.
public void setValue(){

And why stop at method names?
//declare integer variable and initialize to zero
int i = 0;

Trust me, if you don’t understand the code, you won’t understand the above comment either. Comments aren’t for teaching elementary programming. If you can’t read variable declarations, you have bigger problems to worry about. (On a serious note, using methods using recursion, call back methods, etc, maybe should provide a note and maybe a link to wikipedia on how the technique works)

All examples come from real code.

Error Messages: On_Error_Insult_User

In the good ole days, if we hit an error message, we’d just write to the console a routine insult to the user.

If input_arg<0 then Print “You are such a dumb ass”

We now hide our contempt in secret code

If input_arg<0 then Print “Please contact your administrator”
/* You are such a dumb ass */

Sometimes we prefer the “I’m smarter than the runtime” pattern and send developers on a goose chase.