I'm stuck with a problem regarding checkboxes from a WPF application to a SQL database.
I've arrived at a point where I can update the value of a specific item into the database but I can only update the value or from 0 to 1 or from 1 to 0, I'm searching for an IF Statement kind of thing, and I think I'm near the solution but the code isn't working and gives me the error" there's an error near =" PLEASE HELP
private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
{
sqliteCon.Open();
if (sqliteCon.State == System.Data.ConnectionState.Open)
{
var currentRowIndex = dataGrid1.Items.IndexOf(dataGrid1.CurrentItem);//PER IDENTIFICARE LA LINEA CORRENTE
//PROVA5
string q = @"UPDATE tabList
SET selection = (CASE Prova
WHEN tabList.selection.Value = ' 0 '
THEN tabList.selection.Value = ' 1'
ELSE tabList.selection.Value = ' 0 '
END)
WHERE idL = @CURRENT";
SqlCommand cmd = new SqlCommand(q, sqliteCon);
cmd.Parameters.AddWithValue("@CURRENT", currentRowIndex = currentRowIndex + 1);
cmd.ExecuteNonQuery();
MessageBox.Show("Dato Modificato");
}
sqliteCon.Close();
}
Aucun commentaire:
Enregistrer un commentaire