1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| adapter = new SQLiteDataAdapter();
// Requête qui ne pose pas de problème
//adapter.SelectCommand = new SQLiteCommand("select d.id, d.name, d.description from documents d", cnx);
// Requête qui déclenche l'erreur au moment de l'update.
adapter.SelectCommand = new SQLiteCommand("select g.name Groupe, d.name `Nom document`, d.description" +
" from documents d inner join groups g on d.group_id = g.id", cnx);
// Requête en UPDATE qui ne concerne que la table principale
adapter.UpdateCommand = new SQLiteCommand("update documents set name = @name, description = @description " +
"where id = @id", cnx);
adapter.UpdateCommand.Parameters.Add("@name", DbType.String, 100, "name");
adapter.UpdateCommand.Parameters.Add("@description", DbType.String, 100, "description");
var idParam = adapter.UpdateCommand.Parameters.Add("@id", DbType.Int32, 0, "id");
idParam.SourceVersion = DataRowVersion.Original;
table = new DataTable();
adapter.Fill(table);
_bindingSource.DataSource = table; |
Partager