3

I have a SQL Server SPROC that takes a money paramater.

I'm passing in a C# decimal to this SPROC

How do I pass in the decimal from C# to the money type in the SPROC in such a way that I wont loose any values after the point

AJM
  • 32,054
  • 48
  • 155
  • 243

2 Answers2

4

Just initialize the Parameter with a new SqlMoney(decimal) constructor.

SqlParameter parameter = new SqlParameter("@Money", SqlDbType.Money);

See the SQLMoney Constructor documentation.

Joshua Drake
  • 2,704
  • 3
  • 35
  • 54
1

I'd try this : What is the best data type to use for money in c#?

Or you can look into the .Parse overrides. I know theres a lot of format and currency is one of them.

Community
  • 1
  • 1
phadaphunk
  • 12,785
  • 15
  • 73
  • 107