Bug #6863 Int64 Support in MySqlCommand Parameters
Submitted: 28 Nov 2004 18:28 Modified: 29 Nov 2004 21:56
Reporter: Chris Guidry Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.2.gamma OS:Microsoft Windows (WinXP)
Assigned to: Reggie Burnett CPU Architecture:Any

[28 Nov 2004 18:28] Chris Guidry
By looking at the source for the MySqlParameter class, it looks like there was a cut-and-paste error at lines 422-423 (MySqlParameter.SetTypeFromValue()):

case TypeCode.Int64: SetDbType( DbType.UInt64 ); break;
case TypeCode.UInt64: SetDbType( DbType.UInt64 ); break;

Unless there is a deeper reason that Int64s are troubling, it looks like this is a simple code error, and this is the only one transposed in the SetTypeFromValue() method.

How to repeat:
Attempt to create a MySqlParameter as follows:

long x = long.MinValue;
MySqlParameter param = new MySqlParameter("myparamname", x);

This results in an error attempting to convert the negative Int64 to a UInt64.

Suggested fix:
case TypeCode.Int64: SetDbType( DbType.Int64 ); break;
case TypeCode.UInt64: SetDbType( DbType.UInt64 ); break;

A temporary workaround would be to set the DbType manually in code after setting up the parameter as shown.
[29 Nov 2004 21:56] 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