You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Invalid cast from 'System.String' to 'System.TimeSpan'." is thrown when getting value of output parameter which its type is TIME #680
I got this exception when trying get the output value of TIME
System.InvalidCastException : Invalid cast from 'System.String' to 'System.TimeSpan'.
StackTrace:
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at MySqlConnector.Core.DbTypeMapping.DoConversion(Object obj) in C:\projects\mysqlconnector\src\MySqlConnector\Core\DbTypeMapping.cs:line 22
at MySqlConnector.Core.StoredProcedureCommandExecutor.SetParams() in C:\projects\mysqlconnector\src\MySqlConnector\Core\StoredProcedureCommandExecutor.cs:line 108
at MySql.Data.MySqlClient.MySqlCommand.ReaderClosed() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlCommand.cs:line 452
at MySql.Data.MySqlClient.MySqlDataReader.DoClose() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 445
at MySql.Data.MySqlClient.MySqlDataReader.Dispose(Boolean disposing) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 282
It looks like you might be using a stored procedure with an OUT parameter. Can you provide more details on how to reproduce this, e.g., table definition, stored procedure definition, sample code?
I experienced the same issue when the data type of OUTPUT parameter is BOOL. The exception said that "Object of type 'System.SByte' cannot be converted to type 'System.Boolean'." when I tried to map the OUTPUT to a bool variable.
Could you have a check?
I'll release 0.57.0-beta9 with this fix soon. The beta versions are tested and reliable enough to run in production; they just haven't shipped as a "stable" release yet due to breaking API changes in this series.
Activity
bgrainger commentedon Aug 14, 2019
It looks like you might be using a stored procedure with an
OUTparameter. Can you provide more details on how to reproduce this, e.g., table definition, stored procedure definition, sample code?nhathongly commentedon Aug 14, 2019
My stored procedure is simply like this
I'm totally new to MySql, so I don't know if I get any mistake. It worked perfectly with MySql.Data-8.0.16
Convert output TIME parameters. Fixes #680
Convert output TIME parameters. Fixes #680
nhathongly commentedon Aug 30, 2019
Hi there,
I experienced the same issue when the data type of OUTPUT parameter is BOOL. The exception said that "Object of type 'System.SByte' cannot be converted to type 'System.Boolean'." when I tried to map the OUTPUT to a
boolvariable.Could you have a check?
Thanks
nhathongly commentedon Aug 30, 2019
When I executed the following script, I saw that the DTD_IDENTIFIER value in
information_schema.parametersof a BOOL parameter was TINYINT(1)nhathongly commentedon Aug 30, 2019
Seem it will be fixed when 782a765 is released
@bgrainger may I know when will we have the next release? Thank you in advance
bgrainger commentedon Aug 30, 2019
I'll release 0.57.0-beta9 with this fix soon. The beta versions are tested and reliable enough to run in production; they just haven't shipped as a "stable" release yet due to breaking API changes in this series.
bgrainger commentedon Aug 30, 2019
0.57.0-beta9 is available with this fix.