appropriate C# types for SqlDbType.Money and SqlDbType.DateTime?

  • Thread starter Thread starter jason
  • Start date Start date
J

jason

hello all,

silly question, but i can't find a thread that answers it. i have
stored procedures that have output parameters of the datatypes Money
and DateTime.

i have the following sample code to extract those parameters into class
properties:

public float P1 = (float) oSqlCmd.Parameters["@Money1"].Value;
publid DateTime P2 = (DateTime) oSqlCmd.Parameters["@Date1"].Value;

however, those are not legal implicit conversions. so my questions are:

1) what's the appropriate datatype to use for members in c# classes for
these datatypes?
2) what's the appropriate way to convert from these datatypes to the c#
datatypes (unless of course implicit conversion is possible)

thanks for any help,

jason
 
Hi,

IIRC there is an article in MSDN about this.

Money can be represented as decimal and DateTime with DateTime :)

In anyway you should use the correct Convert.ToXXXX method


Cheers,
 
Back
Top