text box and SqlDecimal datatypes

M

Mark

Hi all, I have a DAL which takes in a value as shown below ready for my
MSSQL stored procedure.

protected SqlDecimal _annualLeave = SqlDecimal.Null;
public SqlDecimal AnnualLeave
{

get {return _annualLeave;}

set{ _annualLeave = value;}

}

I have a problem where when I try to pass in information from a textbox on a
ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!

I thought I could just go..

((System.Data.SqlDecimal)AnnualLeave.Text)

Where AnnualLeave.Text is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
(Which is fair enough)

So, I tried

((System.Data.SqlDecimal)(Convert.ToDecimal(AnnualLeave.Text))

but for some reason, this rounds the number to an integer!! e.g. 12.2
becomes 12!!!!!

Can someone please tell me what am I doing wrong here, it's been a long day
:p

Thanks
Mark
 
M

Mark

Hi Onin, I was actually doing this originally and still get the same
problem.

Thanks for your advice
Cheers
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top