Hi

I have been having some trouble with the TimeAsTimeSpanType  when
trying to use it with the Sybase Advantage Database. I finally traced
the issue down to the Set method:

public override void Set(IDbCommand st, object value, int index)
{
        DateTime date = BaseDateValue.AddTicks(((TimeSpan)value).Ticks);
        ((IDataParameter) st.Parameters[index]).Value = date;
}

which converts the TimeSpan object into a DateTime then assigns it to
the parameter. If I changed this code to

((IDataParameter)st.Parameters[index]).Value = value;

it works fine for the Sybase Advantage Database.

Unfortunately this Set method does not work on Sql Server. Apparently
there is a known bug in Sql Server so that it converts any parameter
of DbType.Time to DbType.DateTime, see link below:

http://connect.microsoft.com/VisualStudio/feedback/details/381934/sqlparameter-dbtype-dbtype-time-sets-the-parameter-to-sqldbtype-datetime-instead-of-sqldbtype-time

It is not clear to me how the Set method of TimeAsTimeSpanType can be
fixed so it works with both databases, since Sql Server requires a
DateTime type and Sybase Advantage Database requires a TimeSpan.

One solution is to make make another Type class specifically for
Advantage but I would really like to TimeAsTimeSpanType so it works on
both DBMS.

Any help would be gratefully appreciated.

Thanks
Michael

Reply via email to