Why when I save a float value into database (the data type is float as well), for example 24,62 in database is writen as 24,6200008392334. I have entered only 2 decimals, but in db there is plenty of them.

This is how I have:

string Together = textBoxAmount.Text;
string[] Seperated = Together.Split(' ');
float MyAmount = float.Parse(Seperated[0]);

In the "textBoxAmount.Text" it`s just a number with € sign. In my case 24,62 €.

Thats why I 1st do a seperation with whitesplace, that I get in array[0] only a string of 24,62. Then I convert it to float. But I do not add F mark correctly (for float).

float is not a precise data type. You should probably be using the money datatype in SQL server to store currency values. Take a look at SQL BOL for float:

Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.