I am storing a 0.000 a System.Decimal in a DataRow.
On retrieval the value is only 0 without the three decimal places.
It looks like the Get property returns System.Decimal. Zero, but
why????
I can't figure out why the design is so that the DataRow "alters" the
value entered.
In my application a decimal column in a row of a specific table has a
fix number of decimal places according to certain premises. The
premises are quite tedious to calculate so it would be VERY nice if I
could figure out the number of decimal places by looking at the value
stored. However since 0 (zero) can't be stored with a fix amount of
decimal places, I have to store the number of decimal places for each
column in a secondary information source. This secondary information
source gets really huge. For example: one table out of 255 has about
7000 rows with three decimal columns per row.
Considering the following code
DataRow myRow = myTable.NewRow( );
Decimal myDec = new Decimal( 0, 0, 0, false, 3 ); // 0.000
Console.WriteLi ne(myDecimal + " " + NumberOfDec(myD ec));
myRow["decimal"] = myDec;
Console.WriteLi ne(myRow["decimal"].ToString() + " " +
NumberOfDec((De cimal)myRow["decimal"]));
Where NumberOfDec is
public static int NumberOfDec(Sys tem.Decimal decVal)
{
int[] bits = System.Decimal. GetBits(decVal) ;
int retVal= Convert.ToInt32 (System.BitConv erter.GetBytes( bits[3])[2]);
return retVal;
}
The output of this code is
0 3
0 0
In other words myDec is 0 (zero) but with 3 decimals. But when adding
it to myRow it loses the information about 3 decimals.
When looking at myDec and myRow["decimal"]) in the QuickWatch myDec's
flag property is 196608 but myRow["decimal"]) flag property is 0.
Any suggestions/explanations, is it a bug??
/Carl 2 3604
why do you have to store the decimal places when they are 0? Just to display
the in the DataRow? Then why don't you just format the output to show 3
decimal places?
Maybe I don't understand your question but it seems like you are storing
data unnecessarily.
"Carl G" <ge*****@hotmai l.com> wrote in message
news:86******** *************** ***@posting.goo gle.com... I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places.
It looks like the Get property returns System.Decimal. Zero, but why???? I can't figure out why the design is so that the DataRow "alters" the value entered.
In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The premises are quite tedious to calculate so it would be VERY nice if I could figure out the number of decimal places by looking at the value stored. However since 0 (zero) can't be stored with a fix amount of decimal places, I have to store the number of decimal places for each column in a secondary information source. This secondary information source gets really huge. For example: one table out of 255 has about 7000 rows with three decimal columns per row.
Considering the following code
DataRow myRow = myTable.NewRow( );
Decimal myDec = new Decimal( 0, 0, 0, false, 3 ); // 0.000 Console.WriteLi ne(myDecimal + " " + NumberOfDec(myD ec));
myRow["decimal"] = myDec; Console.WriteLi ne(myRow["decimal"].ToString() + " " + NumberOfDec((De cimal)myRow["decimal"]));
Where NumberOfDec is
public static int NumberOfDec(Sys tem.Decimal decVal) { int[] bits = System.Decimal. GetBits(decVal) ; int retVal= Convert.ToInt32 (System.BitConv erter.GetBytes( bits[3])[2]); return retVal; }
The output of this code is 0 3 0 0
In other words myDec is 0 (zero) but with 3 decimals. But when adding it to myRow it loses the information about 3 decimals.
When looking at myDec and myRow["decimal"]) in the QuickWatch myDec's flag property is 196608 but myRow["decimal"]) flag property is 0.
Any suggestions/explanations, is it a bug??
/Carl
> why do you have to store the decimal places when they are 0? Just to display the in the DataRow? Then why don't you just format the output to show 3 decimal places?
I don't want to store the decimal places. I want to use the fact that
System.Decimal holds the information for me. When the user changes the
field that was 0 (to for instance 0.1234) I want to be able to easily
understand how many decimal places it should have by looking at the
prvious value. It works fine for instance if the value is 1.23 and the
user enters 1.5644, I then now that I should round it to two decimals
1.56
In my application, the number of decimal places can vary for the same
column between different data rows depending on the value of other
columns. Calculating this takes time. So by using the fact that
System.Decimal stores the number of decimal places, I could have speed
things up.
Maybe I don't understand your question but it seems like you are storing data unnecessarily.
Yes it is unnecessarily. But I do not have a choice since I can't
store 0 in the datarow as 0.000. Storing 3.000 works fine, but not
0.000. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carl G |
last post by:
I have a DataSet with a couple of tables. I have noticed that when I
am trying to store a Decimal 0.000 in a datarow, the value is changed
to 0, without the information about its decimalplaces.
Storing 3.000 works fine but not 0.000. Why is that?
|
by: anon |
last post by:
I have a datatable of values and I am trying to obtain the values of a range
of the columns.
Imagine I have a table defined with columns headed "A" through to "Z"
Now I decide that I want to count up the amounts between columns E to M
Note:All the columns are defined as decimal.
I have a main datatable defined at dtMain with all the columns and data in
|
by: Chris Ericoli |
last post by:
Hi,
I am working with an 'in session' ado dataset with an asp.net application.
My dataset is comprised of two tables, one of which maintains a few
calculated datacolumns. For some reason these datacolumns do not trigger
their expression when other columns from which the expressions are derived
are updated. Below is a basic example of what I am doing.
User enters values into an asp.net form and clicks a button.
Retrieve dataset from...
|
by: Bruce Wiebe |
last post by:
hi all
im having a problem accessing a text file on my hard disk after ive
created it and added some text to it it would appear that the file is
still locked.
What happens is this i have three buttons on a windows form that provide
three options for the user the process goes like this
user clicks button one and a web service is called that dwnloads a list
|
by: harsha reddy |
last post by:
Dear All,
I have a front end form which has a couple of dropdown
menus which select data from the database based on the value selected,
the stored procedure which the program accesses outputs diffrent columns
when different values( currently 2) from the drop down are chosen. I
also have a Datagrid with bound columns which has all the columns that
can be returned, this datagrid has a couple of date columns when i
select one value from the...
| |
by: Carl G |
last post by:
I am storing a 0.000 a System.Decimal in a DataRow.
On retrieval the value is only 0 without the three decimal places.
It looks like the Get property returns System.Decimal.Zero, but
why????
I can't figure out why the design is so that the DataRow "alters" the
value entered.
In my application a decimal column in a row of a specific table has a
fix number of decimal places according to certain premises. The
|
by: =?Utf-8?B?QmFidU1hbg==?= |
last post by:
Hi,
I have a GridView and a SqlDataSource controls on a page. The SqlDataSource
object uses stored procedures to do the CRUD operations. The DataSource has
three columns one of which - "Modified" of type DateTime - is hidden since it
should not be edited by a user. The system handles the update for this
column. So, I have hidden (Visible=false) this column on the grid. In order
to access the value in this field, I have created a...
|
by: suganya |
last post by:
Hi
I have to insert two textbox values into the database. In sql server 2005, I have the table named Rs with the following fields
Rs decimal(2, 2)
date1 datetime
In front end I have given the coding as
Imports System.Data
|
by: a573851 |
last post by:
I have a very lengthy stored procedure that I just inherited. Apparently this stored proc performs poorly. I am reviewing it to see where I can add some efficiencies. I would like to know if there are any tips/tools/doc available that could assist me in UDB stored procedure performance. I see a lot out there on SQL Server, but I can't seem to find any tips for UDB. The procedure is as follows:
DROP SPECIFIC PROCEDURE...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |