473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

formatting numbers

i'am using the following statement to format a aql string
sql=string.format("INSERT INTO werkboek VALUES {0}, {1}....;"
m_WNR, m_Aantal...)
Aantal is a decimal and evaluates into 2.5D. Evalutating the sql strin
i get:
"INSERT INTO werkboek VALUES 7, 2,5....;"
I've changed te code for the placeholder {1} to {1:#.00} in order to
change te output to 2.5 instead of 2,5 but no luck.
Is there a other way to change ste code to get te requered output te
read:
"INSERT INTO werkboek VALUES 7, 2.5....;"

Thanks in advance
Alexander M. Polak
mailto:am******@highpotech.nl
Jul 21 '05 #1
4 1228
Highpotech IT <am******@highpotech.nl> wrote:
i'am using the following statement to format a aql string
sql=string.format("INSERT INTO werkboek VALUES {0}, {1}....;"
m_WNR, m_Aantal...)
Aantal is a decimal and evaluates into 2.5D. Evalutating the sql strin
i get:
"INSERT INTO werkboek VALUES 7, 2,5....;"
I've changed te code for the placeholder {1} to {1:#.00} in order to
change te output to 2.5 instead of 2,5 but no luck.
Is there a other way to change ste code to get te requered output te
read:
"INSERT INTO werkboek VALUES 7, 2.5....;"


Rather than formatting the values, use parameters instead.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Tanks.
Using parems creates a new problem the one i wantted to avoid. So your
suggestion is no answer to the quistion at hand
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Rather then using an other approch I'like to use the one i want and to
solve the problem at hand.

Tanks anyway

Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MP***********************@msnews.microsoft.c om>...
Highpotech IT <am******@highpotech.nl> wrote:
i'am using the following statement to format a aql string
sql=string.format("INSERT INTO werkboek VALUES {0}, {1}....;"
m_WNR, m_Aantal...)
Aantal is a decimal and evaluates into 2.5D. Evalutating the sql strin
i get:
"INSERT INTO werkboek VALUES 7, 2,5....;"
I've changed te code for the placeholder {1} to {1:#.00} in order to
change te output to 2.5 instead of 2,5 but no luck.
Is there a other way to change ste code to get te requered output te
read:
"INSERT INTO werkboek VALUES 7, 2.5....;"


Rather than formatting the values, use parameters instead.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters

Jul 21 '05 #4
Alexander M. Polak <am******@highpotech.nl> wrote:
Using parems creates a new problem the one i wantted to avoid. So your
suggestion is no answer to the quistion at hand


Well, I'd suggest that using parameters is still likely to be a better
solution, even if you then have to solve other problems - embedding
literals in SQL statements comes with all kinds of problems. (SQL
injection attacks, determining the input format for things like dates,
numbers etc, performance, to name just a few.)

However, if you specify CultureInfo.InvariantCulture before your format
string, I think that will solve your immediate problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5

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

Similar topics

3
by: Dan Sommers | last post by:
Hi, I have a class whose objects represent physical quantities including uncertainties and units, and I would like more control over the way they print. I have a __str__ method which outputs...
4
by: Tommi Mäkitalo | last post by:
Hi I need to format floating-point-numbers with exact 2 digits after decimal point. I could use printf with "%.2f", but it don't use std::locale. Any ideas? -- Tommi Mäkitalo
4
by: Dave Brydon | last post by:
Access 2003 I have a combo box in my personnel table, which draws its data from a trade code table; the original field in the code table, is numeric, Long Integer, and formatted with 5 zero's . ...
4
by: John Sutor | last post by:
I need some code that, on each keyup event, will take all of the numbers typed into the text box and format as they type to look like this 100 1,000 10,000 100,000 1,000,000 John S
7
by: ilona | last post by:
Hi all, I store phone numbers in the database as 123447775665554(input mask is used for input, and some numbers have extensions), and I also know from db if the number is Canadian, US, or some...
9
by: Markus | last post by:
Hi all, two questions on formatting numbers: - Given is a decimal/money datatype in SQL-Server, e.g. decimal(9,4), thus displaying a value like 13.2000 How can I prevent to display the...
5
by: Carla | last post by:
I have Access 2000. I made a mailing list database and for the life of me can't remember how to format the zip code field so it will print on the label as xxxxx-xxxx. I have tried various - 9, #,...
6
by: Rafael Olarte | last post by:
The goal of this project is to output the following information as follows: 34.5 38.6 4.1 42.4 3.8 close 46.8 4.4 big change. The values of the first colunm are obtain from a file...
2
by: jerryyang_la1 | last post by:
I need some advice on formatting numbers using PHP. My database holds numbers like: 10 0.2 I need these to be displayed as 10.00
3
by: sparks | last post by:
We have one database that they are constantly reformatting their inputs. I asked about the changes and they can never get the same types of numbers from the people. some are -.95 and later they...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.