Skip to content

Commit

Permalink
If a parameter is NULL or DBNull then its size needs to be zero other…
Browse files Browse the repository at this point in the history
…wise the parameter gets treated as an empty string which is a different thing to a NULL. Microsoft will send a true NULL, this will get mono to do the same.
  • Loading branch information
nealef committed Jan 5, 2012
1 parent ff9af04 commit 4109fd6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
Expand Up @@ -522,6 +522,13 @@ private void WriteParameterInfo (TdsMetaParameter param)
size = param.GetActualSize ();
}

/*
* If the value is null, not setting the size to 0 will cause varchar
* fields to get inserted as an empty string rather than an null.
*/
if (param.Value == null || param.Value == DBNull.Value)
size = 0;

// Change colType according to the following table
/*
* Original Type Maxlen New Type
Expand Down

1 comment on commit 4109fd6

@Danre
Copy link

@Danre Danre commented on 4109fd6 Mar 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change, the bug occurred:
https://bugzilla.xamarin.com/show_bug.cgi?id=16892

Please sign in to comment.