Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeSpan FbCommand parameter throws InvalidCastException with embedded FB [DNET289] #300

Closed
firebird-automations opened this issue Jan 15, 2010 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: @pcisar

I have a method parameter 'time' of type nullable<TimeSpan>. When I
use it with Firebird 2.1.2, everything is ok, with Firebird embedded I
get InvalidCastException.

This is part of my SQL command:

if (time.HasValue)
sqlText.AppendLine(" AND time_from_t19 <= @time and time_to_t19 >= @time");
(...)
if (time.HasValue)
command.Parameters.AddWithValue("time", time.Value);

Exception:

Type: InvalidCastException
Message: Unable to cast object of type 'System.TimeSpan' to type
'System.Byte[]'.
Source: XXXXXXXX.DBLayer
Target site: FirebirdSql.Data.FirebirdClient.FbDataReader
ExecuteReader(FirebirdSql.Data.FirebirdClient.FbCommand)

When I use this instead, everything is ok:

if (time.HasValue)
sqlText.AppendLine(" AND time_from_t19 <= '" +
time.Value.ToString() + "' and time_to_t19 >= '" +
time.Value.ToString() + "'");

Commits: 09e77a3

@firebird-automations
Copy link
Author

Commented by: @pcisar

This issues was DNET288 before tracker crash.

@firebird-automations
Copy link
Author

Modified by: @pcisar

security: Managers [ 10013 ] =>

@firebird-automations
Copy link
Author

Commented by: @pcisar

Originally reported by Pavel Kopecky.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Actually it looks easy to improve this to support scenario when no datatype is set explicitly by developer, to just go to database and ask for it. Look at DNET290.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Duplicate [ 3 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants