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

4
  • how do you passing decimal value to sproc? Parameter with type Money? Commented Apr 5, 2012 at 13:27
  • 1
    here is the info you seek stackoverflow.com/questions/6075067/… Commented Apr 5, 2012 at 13:28
  • Reniuz yes param with type money Commented Apr 5, 2012 at 13:30
  • 1
    "Won't lose any values after the point" - if you have any values after the 4th, you're doomed, since money has a fixed scale of 4. Commented Apr 5, 2012 at 13:31

2 Answers 2

4

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

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

See the SQLMoney Constructor documentation.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.