A
A
Andrey Fomin2021-01-07 10:28:28
SQL
Andrey Fomin, 2021-01-07 10:28:28

How to fix System.Data.SQLite.SQLiteException: "SQL logic error near "(": syntax error" error?

Hello!
There is the following code for connecting to the database and executing an sql query:

SQLiteConnection connect = new SQLiteConnection("Data source = accounts.db");
            connect.Open();
            try
            {
                SQLiteCommand command = new SQLiteCommand($"UPDATE users (Name, Surname) SET ('{NameField.Text}','{SurnameField.Text}') WHERE Login = '{LoginField.Text}'", connect);
                command.ExecuteNonQuery();
            }
            finally
            {
                MessageBox.Show($"Изменения сохранены!");
                connect.Close();
            }

It also has the following error:
System.Data.SQLite.SQLiteException: "SQL logic error
near "(": syntax error"

And this error came out on this line:
command.ExecuteNonQuery();
And from all this the question arose:
Where is the error and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-01-07
@a63826ndrew

Your query syntax is incorrect.
UPDATE is written like this:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question