473,796 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text box and SqlDecimal datatypes

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.S qlDecimal)Annua lLeave.Text)

Where AnnualLeave.Tex t is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.Sq lTypes.SqlDecim al" error
(Which is fair enough)

So, I tried

((System.Data.S qlDecimal)(Conv ert.ToDecimal(A nnualLeave.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
Nov 19 '05 #1
2 1425

Hi Mark,

just use Convert.ToDecim al(AnnualLeave. Text)

HTH,

"Mark" <ma**@Z-Zvolution.nZt> wrote in message
news:OQ******** ******@TK2MSFTN GP12.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.S qlDecimal)Annua lLeave.Text)

Where AnnualLeave.Tex t is the value of my textbox on my form, but I
received
"Cannot convert type 'string' to 'System.Data.Sq lTypes.SqlDecim al" error
(Which is fair enough)

So, I tried

((System.Data.S qlDecimal)(Conv ert.ToDecimal(A nnualLeave.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

Nov 19 '05 #2
Hi Onin, I was actually doing this originally and still get the same
problem.

Thanks for your advice
Cheers
Mark
"Onin Tayson" <Le*********@co mpaid.com> wrote in message
news:O%******** ********@tk2msf tngp13.phx.gbl. ..

Hi Mark,

just use Convert.ToDecim al(AnnualLeave. Text)

HTH,

"Mark" <ma**@Z-Zvolution.nZt> wrote in message
news:OQ******** ******@TK2MSFTN GP12.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.S qlDecimal)Annua lLeave.Text)

Where AnnualLeave.Tex t is the value of my textbox on my form, but I
received
"Cannot convert type 'string' to 'System.Data.Sq lTypes.SqlDecim al" error
(Which is fair enough)

So, I tried

((System.Data.S qlDecimal)(Conv ert.ToDecimal(A nnualLeave.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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
6154
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number. "Decimal Number" sometimes serves to distinguish Base 10 numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal Number" serves to differentiate a number from an integer. For the rest of this post I shall only use either...
5
9930
by: Amit | last post by:
I am facing a problem while using SQL Server with VB application. Implicit conversion from datatype text to nvarchar is not allowed. Use the convert function to run this query. When i see the trace file, i see one stored procedure called but no lines of code get executed, and immediately after that the ROLLBACK TRANSACTION occurs and the applications fails. But to my surprise i am able to do the same thing on a different
0
3241
by: wooks | last post by:
<?xml version="1.0" ?> - <xsd:schema targetNamespace="urn:faster:userlogin" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:faster:userlogin"> <xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\login.xsd" /> <xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\password.xsd" /> - <xsd:complexType name="userloginType"> - <xsd:all>
1
10627
by: Jan Agermose | last post by:
Im writing information into an existing excel document using a connection string like: strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Filename + ";Extended Properties=\"Excel 8.0;HDR=yes;\""; and one of to methods for inserting data. First I simply tried building insert statements as strings "insert into (, ) values ('Some text', 42)"
6
3952
by: robin9876 | last post by:
In an Access 97 (and 2000) database that has linked tables to Oracle which is showing some fields as text when they are numbers in Oracle. In Oracle they are specified to a size e.g. Number(38). This is causing some issues when trying join different tables in a query. How can the correct datatype be defined in Access?
0
3581
by: Daniel Zelisko | last post by:
Hello Could anyone tell me how to send a null decimal value to the sql server depending on its value? The following code gives me an error: System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. I figured out SqlDecimal.Null is used only with db Money fields. But when I changed SqlDecimal.Null to DBNull.Value I got the error: CS0173 Type of conditional expression can't be...
2
1960
by: | last post by:
I'm working primarily in ASP and transitioning to ASP.NET. This is probably entered to the wrong group but I'm not sure of what precise database technology I'm referencing. I have written a decent little "codewriter" utility that writes web admin forms, stored procedure code, and the functions (in ASP) that calls the sprocs that interface with the database.
4
1276
by: Pieter | last post by:
Hi, I have a variable (m_sngPrixNetUnitaire) which is of type Single. When I want to write the value to my SQL SERVER 2000, I put this value in my DAL (MyDal.PrixNetUnitaire), which is of datatype SqlDecimal. But during the conversion the value changes, and MyDal.PrixNetUnitaire =4.4749999999999996D... Does anybody has any idea why this happens? Is this normal? Or is it a bug?
0
1885
by: Crazy Cat | last post by:
How in the hell does one specify the precision and scale for the SQLDecimal type? I am writing a user defined CLR SQL Server function and one of the function parameters is a decimal value which in SQL Server would be type numeric(18,6), but the only type that seems to be an equivalent on the VB 2005 side is SQLDecimal, but there seems no way to set the precision and scale for this (outside of using a new constructor, which is not allowed...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.