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
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() + "'");
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.
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
The text was updated successfully, but these errors were encountered: