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
MarkHi Mark,
just use Convert.ToDecimal(AnnualLeave.Text)
HTH,
"Mark" <mark@.Z-Zvolution.nZt> wrote in message
news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> 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
>
Hi Onin, I was actually doing this originally and still get the same
problem.
Thanks for your advice
Cheers
Mark
"Onin Tayson" <Leon_Tayson@.compaid.com> wrote in message
news:O%23qlxt44FHA.1140@.tk2msftngp13.phx.gbl...
> Hi Mark,
> just use Convert.ToDecimal(AnnualLeave.Text)
> HTH,
> "Mark" <mark@.Z-Zvolution.nZt> wrote in message
> news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
on
>
0 comments:
Post a Comment