| Bug #6863 | Int64 Support in MySqlCommand Parameters | ||
|---|---|---|---|
| Submitted: | 28 Nov 2004 19:28 | Modified: | 29 Nov 2004 22:56 |
| Reporter: | Chris Guidry | ||
| Status: | Closed | ||
| Category: | Connector/Net | Severity: | S2 (Serious) |
| Version: | 1.0.2.gamma | OS: | Microsoft Windows (WinXP) |
| Assigned to: | Reggie Burnett | Target Version: | |
[29 Nov 2004 22: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
http://www.mysql.com/doc/en/Installing_source_tree.html

Description: 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); someCommand.Parameters.Add(param); someCommand.ExecuteXYZ(); 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.