473,396 Members | 1,858 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,396 software developers and data experts.

Single DataType and decimal separator

Lets say I need to do something like this when running sql-sentences...

Private Sub InsertIntoTable(ByVal ProductID As Integer, ByVal Amount As
Single)
Dim sql as String = String.Format("INSERT INTO MyTable (ProductID,
Amount) VALUES ({0}, {1})", ProductID, Amount)
'...code continues...
End Sub

....in this case problem will be "Amount"- Single type variable, because
for example here in Finland our Decimal symbol is , (= comma) not . (=
point).

If amount is one and half (1.5) then our form is 1,5 and it's not
correct form for sql-sentences directly - so what's the recommended way
for these to convert into correct form? I have handled single numbers
like this way...

Dim strAmount As Single = Amount.ToString.Replace(",", ".")

....and then used strAmount like...

Dim sql as String = String.Format("INSERT INTO MyTable (ProductID,
Amount) VALUES ({0}, {1})", ProductID, strAmount)

....but I assume it's not good to do it like this way :)
Nov 21 '05 #1
2 1163
"Mika M" <mahmik_nospam@removethis_luukku.com> schrieb:
Lets say I need to do something like this when running sql-sentences...

Private Sub InsertIntoTable(ByVal ProductID As Integer, ByVal Amount As
Single)
Dim sql as String = String.Format("INSERT INTO MyTable (ProductID,
Amount) VALUES ({0}, {1})", ProductID, Amount)
'...code continues...


Instead of building the command strings yourself, use a parameterized
command object ('SqlCommand.Parameters').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
Mika,

In addition to Herfried,

Be aware that in the case of the parameters OleDb and SQLClient have
different behaviour.

Therefore look very good which you use.
OleDbCommand.Parameters <> SQLCommandParameters etc.

I hope this helps,

Cor
Nov 21 '05 #3

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

Similar topics

8
by: SAN CAZIANO | last post by:
i have to do in the onkeypress or in onchange the float (real) field validation I try something: function ValidaCampo(nomeCampo,TotInteri,TotDecimali) {...
0
by: Tobias | last post by:
Hi all, is it possible to set decimal-format in any way by using a variable or similar? Example: <xsl:variable name="myseparator" select="@separator"/> <xsl:decimal-format...
4
by: John Bowman | last post by:
Hi, A couple Q's , so I've come to the experts<g>. 1) I need a definitive answer to the following debate. I've got a couple developers who disagree on the following question. We've got an XML...
0
by: alederer | last post by:
Hallo! I have a problem using SQLBindParameter for columns of datatype DOUBLE or REAL. e.g. I have an insert statement where i wan't to insert the value 100.10 into a DOUBLE column. For the...
4
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...
1
by: Savas Ates | last post by:
I have a column in my table BizdekiFiyat . The datatype = float length =8 (to save money values).. It is impossible to change these attributes for some reasons. It has records like This ...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
3
by: DustWolf | last post by:
Hello, I am wondering, what is the standard for including decimal numbers in XML code? What determines what is the decimal delimiter and what can be the grouping symbol? I have just realized...
3
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have a table column of SQL smallmoney type which I am updating via a form input field defined as decimal. If I enter, say, 51.09 via the decimal input field (representing $51.09), this is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
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...
0
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,...

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.