Answer the question
In order to leave comments, you need to log in
How to submit a request?
Hello!
There is such a form for making transfers to other users.
And when you click on the "Perform translation" button, according to the original idea, the corresponding value is taken from the table and updated, but there is a moment that was written not quite right.
The CashAmount column is of type INTEGER if so
Here is the table:
Here is the button processing:
SQLiteConnection Transfer = new SQLiteConnection("Data source = accounts.db");
Transfer.Open();
try
{
SQLiteCommand cmd = new SQLiteCommand($"UPDATE users SET CashAmount = 'CashAmount + {textBox2.Text}' WHERE Login = '{LoginField.Text}'", Transfer);
cmd.ExecuteNonQuery();
}
finally
{
MessageBox.Show($"Операция выполнена успешно!");
Transfer.Close();
}
Answer the question
In order to leave comments, you need to log in
If you omit a bunch of subtleties about SQL injection and data validation, then just change
SQLiteCommand cmd = new SQLiteCommand($"UPDATE users SET CashAmount = 'CashAmount + {textBox2.Text}' WHERE Login = '{LoginField.Text}'", Transfer);
SQLiteCommand cmd = new SQLiteCommand($"UPDATE users SET CashAmount = CashAmount + '{textBox2.Text}' WHERE Login = '{LoginField.Text}'", Transfer);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question