[Solved] Error: You have an error in your SQL syntax – but SQL statement works


Be aware that if this runs on your machine (slovak culture settings) that the value in double priemer gets translated to string as e.g. “586,935”. That is not what you want, as , has different meaning in SQL than ..
Simplest way to fix the problem is to use

string query2 = "UPDATE feture SET priemer="+priemer.ToString(CultureInfo.InvariantCulture)+" WHERE ID="+i;

You may have found this issue, if you printed the query2 before posting it here, by the way.

Be also aware that this is in no way a best practice to call a query in C#, a nice clue for how to create a parametrised query may be found here.

3

solved Error: You have an error in your SQL syntax – but SQL statement works