Page 1 of 1

Using "WHERE" in command with MySQLDependecy

Posted: Thu 18 Oct 2018 22:07
by killerowns
Hi, I'm testing the dotnet conector for mysql and I'm trying to fire OnChange handler in a WHERE statement in my sql command but when I update, insert or delete something in table wich is not in WHERE statement, the envent fires even.

This is my code:

void Start()
MySqlConnection connection = new MySqlConnection(constring);
MySqlCommand Orcamento_Cadastrado = new MySqlCommand("SELECT id, usuario_id, mensagem, lida, data, negocio_id FROM mensagem_usuario WHERE id='0'", connection);

MySqlDependency dependency = new MySqlDependency(Orcamento_Cadastrado, 100);

dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

Is there a way to do this or what I'm doing wrong?

Re: Using "WHERE" in command with MySQLDependecy

Posted: Wed 24 Oct 2018 15:42
by Pinturiccio
MySqlDependency tracks changes for the whole table. It's not possible to track changes only in some specific records. It is not designed for this purpose.