Bug #5602 Possible bug in MySqlParameter(string, object) constructor
Submitted: 15 Sep 2004 22:44 Modified: 16 Sep 2004 19:07
Reporter: Svetoslav Milenov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.0. beta OS:
Assigned to: Reggie Burnett CPU Architecture:Any

[15 Sep 2004 22:44] Svetoslav Milenov
Description:
MySqlParameter(string, object) constructor throws an exception when null value is passed.

How to repeat:
MySqlParameter par = new MySqlParameter("test", null);

Suggested fix:
This fixes the problem for me.

public MySqlParameter(string parameterName, object value)
{
	ParameterName = parameterName;
	Value = value;
	if (Value == null)
		paramValue = null;
	else
		paramValue = MySqlValue.GetMySqlValueFromValue(value);

	if (value is Byte[])
		size = (value as Byte[]).Length;
}

If this implementation is by design, please comment.
[16 Sep 2004 12:55] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fixed.  Thanks for the report.
[16 Sep 2004 14:17] Svetoslav Milenov
Hi, I can not see this change in the bk repository. Do we use the same one? I use, as suggested in the forums:
http://mysql.bkbits.net:8080/connector-net

Thanks
[16 Sep 2004 17:19] Reggie Burnett
You're fast.  I had committed to my repository but had not pushed it to the central one.  Should be there now.
[16 Sep 2004 18:25] Svetoslav Milenov
Thanks for the input.
I have seen the change. I was wondering, isn't it better if when the value is null, to set Value to DBNull.Value? Or it is better the way you have made it? Why?

Btw, if this is not the right place for such a discussions, which is the right one?

Cheers
[16 Sep 2004 19:07] Reggie Burnett
The way I have it is fine since the actual value that is submitted will be tweaked to be DBNull.Value in that case.