Click here to Skip to main content
15,905,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

i want to try create sql command usinf sql formatter however i got problem to double values.
For example my value is:1,44
and my sql command:"INSERT INTO REPORT_DETAILS (BIRIM_FIYAT)VALUES
(1,44)"

i got value caount error
i think its about ',' how can i change this to '.'

What I have tried:

i use cultre info
google searches
Posted
Updated 9-Feb-17 0:21am
Comments
Karthik_Mahalingam 9-Feb-17 3:45am    
show the code for sqlformatter

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

If you use a parameterized query, not only will you not have to worry about culture and formatting issues like this, you'll also avoid SQL Injection[^] vulnerabilities.
C#
double BIRIM_FIYAT;
if (double.TryParse(input, out BIRIM_FIYAT))
{
    using (var connection = new SqlConnection("..."))
    using (var command = new SqlCommand("INSERT INTO REPORT_DETAILS (BIRIM_FIYAT) VALUES (@BIRIM_FIYAT)", connection))
    {
        command.Parameters.AddWithValue("@BIRIM_FIYAT", BIRIM_FIYAT);
        connection.Open();
        command.ExecuteNonQuery();
    }
}


Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
 
Share this answer
 
If you have:
C#
double value = 1.44;
then
C#
String.Format(System.Globalization.CultureInfo.InvariantCulture,"{0}",  value);
produces the expected result.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900