How To Convert Exponent String To Decimal
Apr 10, 2010
I have 6E-11,4.4E-11 values in db and I am converting it to decimal. I have C# code:
string mystring = "6E-11";
decimal myno =Decimal.Parse (mystring, System.Globalization.NumberStyles.AllowExponent);
but it still not work.
View 7 Replies
Similar Messages:
Aug 6, 2010
I'm trying to convert a string to decimal but I get this exception:
Exception Details:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'string' does not contain a definition for 'AsDecimal'
Here is the code:
decimal PriceHT = 0;
var PriceRequest= "SELECT * FROM Price_" + HttpContext.Current.Session["PriceTableId"] ;
foreach (var Price in Database.OpenFile("Base.sdf").Query(PriceRequest)){
PriceHT = PrixceHT + (Price.PT).AsDecimal(); //Price.PT returns a string
}
View 4 Replies
Aug 17, 2010
I have a string, that could look like "123,34", "123123,09", "1234", "123.34", "123123.09"
(Stringrepresentation of 10,2 decimal that will be stored into a MySql DB)
Due to the culture of the ASP.net thread may differ, because my application supports localization, I need to find a safe way to convert the most likely user input into a decimal.
How is that possible?
I tried various Decimal.Parse attemps, that all failed so far.
Solution:
My final solution was a mixed one. I used string replace to ensure my date is formatted into the specified CultureInfo I used for parsing
View 6 Replies
Feb 14, 2011
how to convert the string to 3 decimal place?i want 0.033 for below:
[Code]....
[Code]....
View 2 Replies
Mar 9, 2010
When running our web application the following message appears:
Failed to convert parameter value string to decimal. We believe that the problem might be with the sequence which generates the user_id. The user_id should be the output after successful insert of record. The stored procedure works well from within the DB and Visual Studio. Our DB version: 11gR1 on Windows.The web form has a button event with this c#-code:
[Code]....
[Code]....
View 7 Replies
Oct 9, 2010
i have a strange error creaping into my web app but am unsure as to how to fix it. When i run this code on my debug workstation it works fine but when i transfer it to my server things seam to go wrong.
dev station (windows 7) + VS2010
regional and language settings all set to uk
server (windows 2008r2)
regional and language settings all set to uk
What seams to be happening is that when converting a string to a double it works correctly on the dev environment but moves the decimal place to the end on the server.
example code(vb)
dim lat as string = "52.983829"
dim long as string = "-0.036500"
dim latint as double = lat
dim longint as double = long
now on the dev server the value of latint is 52.983829 as you might expect but on when published to the server it becomes 52983829.0 the same with longint on the dev staion it is -0.036500 but on the server it becomes -36500.0 i get equally confusing problems if i try to change it to an integer instead.
View 2 Replies
Sep 14, 2012
I have one dropdownlist control.
But when I Convert It.
It is giving me error:-
System.FormatException: Input string was not in a correct format.
decimal addDomain = Convert.ToDecimal(ddlAddDomains.SelectedValue);
View 1 Replies
Feb 23, 2010
how to convert decimal to INR currency in asp.net C#. like- 28999345 into 2,89,99,345
View 2 Replies
Dec 21, 2010
In SQL ......
"reading_i" is smallmoney
"reading_f" is smallmoney
CAST(ABS((reading_i - reading_f)) AS VARCHAR)
I want four decimal places alwaysfor example
reading_i = 3.123
reading_f = 1.23
I want 1.8930 (always four decimal places)
View 1 Replies
Feb 9, 2011
is it possible to convert a Currency value $100.00 to a decimal value of 100.00?
View 1 Replies
Jun 25, 2012
i need to convert decimal amount to words for ex: 40300 the Result Should be: Fourty Thousand Three Hundred Rupees only if 40300.35 then: Fourty Thousand Three Hundred Rupees and Thirty Five Paise only.i have tried many Syntax and Functions bt nthing is Working Correctly,
View 1 Replies
Mar 6, 2014
i want to know how to convert number to word , i want only number no decimal or currency .is there any third party tool?
View 1 Replies
Jun 28, 2010
If I have a string/integer that looks like 123, how can I convert that to look like 12.3?Basically what I need is something faster (if possible) than thisMath.Round(Double.Parse(input / 1000), 1).ToString
View 1 Replies
Sep 7, 2010
Just to be forward, my .net and c# expierence is very limited, that one could say I'm a complete noob :) However I do have some grasp on OOP as I usually work in PHP (FWIW). My problem seems to be with this line:
Session["total"] = dt.Compute("SUM(price)", "").ToString();
which will output a total of say "9.2" where as the price is "9.20" from a few record lines as such:
dt.Rows.Add(strRecord, 9.20, dropDownListDistrict_stepTitle.Text);
thus 9.20 + 9.20 = "18.40", but the page displays "18.4".
The label that displays the total sum is:
<asp:Label ID="labelTotal3" runat="server" Text="0" />
From what I've gathered, I'm suffering from some kind of type casting problem? Hopefully I haven't missed anything, its a bit difficult to show all the code but hopefully someone can point me in the right direction? Question is; how can I get an extra decimal place to show up on my sum (or why is it dropping the last decimal place?).
View 6 Replies
Nov 30, 2010
I have below digits. I want to show one digit after to decimal. How to format it?
2.85
2
1.99
I was using ("{0:0.0}". But data showing like
2.9 //It should be 2.8
2.0 //It should be 2
2.0 //It should be 1.9
View 2 Replies
Mar 2, 2011
i have a repeater item that displays a double. occasionally the double seems to be coming out with 3 decimal places like this 1165.833. im trying to force it to two decimal places by wrapping it in a string.format method but it still comes out the same:
<%# String.Format("{0:f2}",DataBinder.Eval(Container.DataItem, "pricerange").ToString())%>
View 3 Replies
Feb 24, 2010
I have a field in my products table called dProductPrice which is a datatype of money. In my datalist i need to display the field as currently it shows price as e,g, 1.3500 but i need it to 2 decimal places so it is 1.35? in my datalist i have done this using the format as well
<%# DataBinder.Eval(Container.DataItem, "dProduct_price", "{0:n2}") %>'
now i have a datatable with a column called cost with datatype decimal.
cartDR["Cost"] = Decimal.Parse(lblProductPrice.Text);
But when i try to populate it i can the input string was not in a correct format. But it works ok if i remove {0:n2}
View 5 Replies
Nov 11, 2010
I'm not getting a trailing zero on currency values and I have no idea why not. This is my code:
[Code]....
Yet this is what is showing up on the screen:
$18.7
Very aggrevating...It should not be doing this as I understand it.
View 4 Replies
May 24, 2012
I have to validate for whether the string is decimal/numeric in code behind in asp.net.
View 1 Replies
Nov 7, 2013
I have qi1 decimal field ... coming error in line ...
txtCostPrice = Convert.ToInt32(((TextBox)GridView2.Rows[i].FindControl("txtcostprice")).Text);
my code
public void savedata() {
con = new SqlConnection(dbcon);
con.Open();
int txtCostPrice = 0;
//int txtSellPrice = 0;
int Primarykey = 0;
[code].....
View 1 Replies
Mar 26, 2010
I read a CSV file into a DataTable.The DataTable in the first image shows each column and type.The types are exactly what they are supposed to be and the data loaded all the rows it was supposed to load.From the second screen shot you can see the database table. SqlBulkCopy is supposed to map column names to database columns by default.According to that logic each column matches up exactly to the database and the column types also match.However,when I run the command it errors on the first row with:
"The given value of type String from the data source cannot be converted to type decimal of the specified target column."
Here is the StackTrace:
"at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata) at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal() at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount) at
[code]...
Anyone have any ideas why this will not import correctly?
http://www.daviddelella.com/Images/Image1.jpg
http://www.daviddelella.com/Images/Image2.jpg
View 4 Replies
Feb 13, 2010
on VWD 2005 this code works fine, but on 2008 it says I haven't created an instance of the object. I want to convert the object connString (a connection string) into a string.
'This acceses the virtual directory web.config file for connection strings
'We have to convert the object to a connection string
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/VirtualDirec")
Dim connString
As System.Configuration.ConnectionStringSettings
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ConnectString1")
Dim strConnString
As
String = connString.ToString().......
View 5 Replies
Dec 7, 2010
If I enter the a location of: Latitude = 28 Degrees, 45 Minutes, 12 Seconds Longitude = 81 Degrees, 39 Minutes, 32.4 Seconds. It gets converted into Decimal Degrees format to be stored in the database with the following code:
Coordinates coordinates = new Coordinates();
coordinates.LatitudeDirection = this.radLatNorth.Checked ? Coordinates.Direction.North : Coordinates.Direction.South;
coordinates.LatitudeDegree = this.ConvertDouble(this.txtLatDegree.Text);
coordinates.LatitudeMinute = this.ConvertDouble(this.txtLatMinute.Text);
coordinates.LatitudeSecond = this.ConvertDouble(this.txtLatSecond.Text);
coordinates.LongitudeDirection = radLongEast.Checked ? Coordinates.Direction.East : Coordinates.Direction.West;
coordinates.LongitudeDegree = this.ConvertDouble(this.txtLongDegree.Text);
coordinates.LongitudeMinute = this.ConvertDouble(this.txtLongMinute.Text);
coordinates.LongitudeSecond = this.ConvertDouble(this.txtLongSecond.Text);
//gets the calulated fields of Lat and Long
coordinates.ConvertDegreesMinutesSeconds();
In the above code, ConvertDouble is defined as:
private double ConvertDouble(string value)
{
double newValue = 0;
double.TryParse(value, out newValue);
return newValue;
}
and ConvertDegreesMinutesSeconds is defined as:
public void ConvertDegreesMinutesSeconds()
{
this.Latitude = this.LatitudeDegree + (this.LatitudeMinute / 60) + (this.LatitudeSecond / 3600);
this.Longitude = this.LongitudeDegree + (this.LongitudeMinute / 60) + (this.LongitudeSecond / 3600);
//adds the negative sign
if (LatitudeDirection == Direction.South)
{
this.Latitude = 0 - this.Latitude;
}
else if (LongitudeDirection == Direction.West)
{
this.Longitude = 0 - this.Longitude;
}
}
If I don't make any change to the latitude or longitude and I click Apply Changes which basically does the above calucation again, it generates a different latitude and longitude in the database. This happens every time I go to edit it and don't make a change (I just click Apply Changes and it does the calculation again with a different result). In the above scenario, the new Latitude and Longitude is: Latitude = 28 Degrees, 45 Minutes, 12 Seconds Longitude = 81 Degrees, 40 Minutes, 32.4 Seconds If I do it again, it becomes:
Latitude = 28 Degrees, 45 Minutes, 12 Seconds Longitude = 81 Degrees, 41 Minutes, 32.4 Seconds The other part of this is that when I go into edit, it takes the decimal degrees format of the latitude and longitude and converts it to the degrees minutes seconds format and puts them into their respective textboxes. The code for that is:
public void SetFields()
{
Coordinates coordinateLocation = new Coordinates();
coordinateLocation.Latitude = this.Latitude;
coordinateLocation.Longitude = this.Longitude;
coordinateLocation.ConvertDecimal();
this.radLatNorth.Checked =
coordinateLocation.LatitudeDirection == Coordinates.Direction.North;
this.radLatSouth.Checked = !this.radLatNorth.Checked;
this.txtLatDegree.Text = coordinateLocation.LatitudeDegree.ToString().Replace("-", string.Empty);
this.txtLatMinute.Text = Math.Round(coordinateLocation.LatitudeMinute, 0).ToString().Replace("-", string.Empty);
this.txtLatSecond.Text = Math.Round(coordinateLocation.LatitudeSecond, 2).ToString().Replace("-", string.Empty);
this.radLongEast.Checked =
coordinateLocation.LongitudeDirection == Coordinates.Direction.East;
this.radLongWest.Checked = !this.radLongEast.Checked;
this.txtLongDegree.Text = coordinateLocation.LongitudeDegree.ToString().Replace("-", string.Empty); ;
this.txtLongMinute.Text = Math.Round(coordinateLocation.LongitudeMinute, 0).ToString().Replace("-", string.Empty);
this.txtLongSecond.Text = Math.Round(coordinateLocation.LongitudeSecond, 2).ToString().Replace("-", string.Empty);
}
From the above examples, you can see that the Minute kept increasing by 1, which would indicate why it is generating a different latitude and longitude in decimal degrees in the database, so I guess the problem is more in the above area, but I am not sure where or why it is doing it?
public void ConvertDecimal()
{
this.LatitudeDirection = this.Latitude > 0 ? Direction.North : Direction.South;
this.LatitudeDegree = (int)Math.Truncate(this.Latitude);
if (LatitudeDirection == Direction.South)
{
this.LatitudeDegree = 0 - this.LatitudeDegree;
}
this.LatitudeMinute = (this.Latitude - Math.Truncate(this.Latitude)) * 60;
this.LatitudeSecond = (this.LatitudeMinute - Math.Truncate(this.LatitudeMinute)) * 60;
this.LongitudeDirection = this.Longitude > 0 ? Direction.East : Direction.West;
this.LongitudeDegree = (int)Math.Truncate(this.Longitude);
if (LongitudeDirection == Direction.West)
{
this.LongitudeDegree = 0 - this.LongitudeDegree;
}
this.LongitudeMinute = (this.Longitude - Math.Truncate(this.Longitude)) * 60;
this.LongitudeSecond = (this.LongitudeMinute - Math.Truncate(this.LongitudeMinute)) * 60;
}
View 2 Replies
Jul 28, 2010
I have project in development where string operations like "Hi " + variable + ", welcome to Project" are used at many places (given example is very minor one).
One of the requirement is to convert it to string.format style.
It is very long and tedious job, where I would not like to break earlier working code due to any human error might happen while converting it.
I would like to if any Macro or VS command which I can create to handle it. Just like we mark block of code and do Extract function in Re-factor options.
View 1 Replies
Aug 22, 2012
i hav one data table in which some decimal values are up 6 decimal places.. im trying to bind that Data table to DataGridView while binding i want to round decimal values up to two decimal palces here is my code
dt.Columns.Add("Orderid", typeof(string));
dt.Columns.Add("tagnumber", typeof(string));
dt.Columns.Add("Minimum Value", typeof(string));
dt.Columns.Add("Maximum Value", typeof(string));
int count = ds.Tables[0].Rows.Count;
for (int i = 0; i < count; i++)
[code]...
hows hould i round up while binding..?
View 1 Replies